colorable 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ac8fe28fac5a9c9eee459a8927d35e94146ed21d
4
- data.tar.gz: cd1262d7726f2cfd0003a0b486115c36cb4223f2
3
+ metadata.gz: 8551829488f48f304ed2f67f7b3557805257249b
4
+ data.tar.gz: e7954149790ea24ad68c0d2874be0c1002a6648a
5
5
  SHA512:
6
- metadata.gz: 9abd7f790c84433b91e95cf3aae951960b355311be9436be65686ee375233611742edcdc53ca4cb1089b74ea8ea5465d5bac89bc47d99ae19920cacc085d46cf
7
- data.tar.gz: 72d843af6dc8e343a96142b78700e2167b99eaa59da813a43b2170e9d94cf7321f737b910327eff8413d2e52fbb603f0c9f3325ca3c16754b42cce55c61d149d
6
+ metadata.gz: b16f6cabc48e8b27d57b3da0f968c68520e198dd83078646d2c49056fc55660a9a6ba9eb8ea99babbbf3f951407cb93b859aa67b5d661014c0871eeed901be35
7
+ data.tar.gz: 1aa34b017811d2e9428f4fa36e1b0ce8c468eb9e824650db27db4de37b8185cbfd9ff1a31ad9b7b07c871e3538b75bc8c3ae3a6c8241047529db1f0ffd88ab47
@@ -64,7 +64,11 @@ module Colorable
64
64
  end
65
65
 
66
66
  def <=>(other)
67
- self.rgb <=> other.rgb
67
+ if [self.name, other.name].any?(&:nil?)
68
+ self.rgb <=> other.rgb
69
+ else
70
+ self.name <=> other.name
71
+ end
68
72
  end
69
73
 
70
74
  @@colorset = {}
@@ -209,8 +209,8 @@ module Colorable
209
209
 
210
210
  alias :to_s :name
211
211
 
212
- def sym
213
- @name.gsub(/\s/, '_').downcase.intern if @name
212
+ def sym(sep='_')
213
+ @name.gsub(/\s/, sep).downcase.intern if @name
214
214
  end
215
215
 
216
216
  def dark?
@@ -1,3 +1,3 @@
1
1
  module Colorable
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -283,4 +283,21 @@ describe Color do
283
283
  Color.new(:black).info.should eql info
284
284
  end
285
285
  end
286
+
287
+ describe "#<=>" do
288
+ context "same colornames are same object" do
289
+ it { Color.new('Green').should == Color.new('Green') }
290
+ end
291
+
292
+ context "different colornames are different object even if its RGB are same" do
293
+ subject { Color.new('Green') }
294
+ it { should_not == Color.new('Lime') }
295
+ its(:rgb) { should == Color.new('Lime').rgb }
296
+ end
297
+
298
+ context "no name object compare by its RGB value" do
299
+ subject { Color.new [0, 1, 2] }
300
+ it { should_not == Color.new([0, 1, 3]) }
301
+ end
302
+ end
286
303
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: colorable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - kyoendo