Skip to content

Commit

Permalink
Merge pull request #52 from syndbg/master
Browse files Browse the repository at this point in the history
Fix `Color.build` ignoring Integers in older Ruby versions
  • Loading branch information
ku1ik committed Mar 15, 2017
2 parents b27e615 + f8c01d9 commit f9785ab
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/rainbow/color.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ def self.build(ground, values)
color = values.size == 1 ? values.first : values

case color
when Integer
# NOTE: Properly handle versions before/after Ruby 2.4.0.
# Ruby 2.4+ unifies Fixnum & Bignum into Integer.
# However previous versions would still use Fixnum.
# To avoid missing `Fixnum` input, call `0.class` which would
# return either `Integer` or `Fixnum`.
when 0.class
Indexed.new(ground, color)
when Symbol
if Named.color_names.include?(color)
Expand Down

0 comments on commit f9785ab

Please sign in to comment.