Skip to content

Commit

Permalink
Merge pull request #37 from tarebyte/fix-nil-error
Browse files Browse the repository at this point in the history
Bugfix: NoMethodError: undefined method `<' for nil:NilClass
  • Loading branch information
Jason Long committed Dec 29, 2014
2 parents a3f82ba + b73cdf7 commit cf638e9
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions lib/geo_pattern/pattern_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,21 @@ def generate_background
end

def generate_pattern
if opts[:generator].is_a? String
generator = PATTERNS[opts[:generator]]
puts SVG.as_comment("String pattern references are deprecated as of 1.3.0")
elsif opts[:generator] < BasePattern
if PATTERNS.values.include? opts[:generator]
generator = opts[:generator]
else
abort("Error: the requested generator is invalid")
generator = nil
unless opts[:generator].nil?
if opts[:generator].is_a? String
generator = PATTERNS[opts[:generator]]
puts SVG.as_comment("String pattern references are deprecated as of 1.3.0")
elsif opts[:generator] < BasePattern
if PATTERNS.values.include? opts[:generator]
generator = opts[:generator]
else
abort("Error: the requested generator is invalid")
generator = nil
end
end
end

if generator.nil?
generator = PATTERNS.values[[PatternHelpers.hex_val(hash, 20, 1), PATTERNS.length - 1].min]
end
generator ||= PATTERNS.values[[PatternHelpers.hex_val(hash, 20, 1), PATTERNS.length - 1].min]

# Instantiate the generator with the needed references
# and render the pattern to the svg object
Expand Down

0 comments on commit cf638e9

Please sign in to comment.