colorable 0.0.7 → 0.0.8

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: 4862f2760ecd40037e08051beda7ced338b1c589
4
- data.tar.gz: f4882f6046fd30d8c098199ccc7681768013cff5
3
+ metadata.gz: cd1ee00539ef3544f0938729f93a1abc32c3b3ec
4
+ data.tar.gz: 72879c844b5456ad6908cf0875cc5468f553b0ea
5
5
  SHA512:
6
- metadata.gz: 9142e066151a08d31ce9b57107d47d1f640432631267f70db272625eaade9bca54da1f7e750686666b1180f6b7e33cd28c4d7fe9bc4524a3c68cfd720226ce8c
7
- data.tar.gz: bba5baf4843abe1c52112b3fc1ee78c4f09066b2b6fb28015ce456aee93cf19e5fc72f653d1693876ef23a44eac2d3262e1e55842cfa6c9bf12201474ba56519
6
+ metadata.gz: a04a172d115e8c82c5f0d6746bebebd90670e74ac8a7a97bf8369c961a37de9e2825ef7ba6f57199862ef0253910af6d79d20ff20ef7bdc8ed925c7296d2694a
7
+ data.tar.gz: fe15f0a313eea761fbd741398159dad8d8aaa26d4f56f74b9ff1ff45a48cfaa571537578b4ccb95db1f02a88919b10ab91ea52ef8f10a3f79e8d4f25eb83a6a2
@@ -1,6 +1,9 @@
1
+ require "forwardable"
2
+
1
3
  module Colorable
2
4
  class Colorset
3
5
  include Enumerable
6
+ extend Forwardable
4
7
 
5
8
  def initialize(colorset=nil)
6
9
  @pos = 0
@@ -8,6 +11,8 @@ module Colorable
8
11
  colorset || COLORNAMES.map { |name, rgb| Colorable::Color.new(name) }
9
12
  end
10
13
 
14
+ def_delegators :@colorset, :size, :first, :last, :to_a
15
+
11
16
  # +Colorset[:order]+ create a ordered colorset by passing a order key.
12
17
  def self.[](order, dir=:+, colorset=nil)
13
18
  rgb = [:red, :green, :blue]
@@ -36,10 +41,6 @@ module Colorable
36
41
  @colorset.each(&blk)
37
42
  end
38
43
 
39
- def size
40
- @colorset.size
41
- end
42
-
43
44
  def at(pos=0)
44
45
  @colorset[(@pos+pos)%size]
45
46
  end
@@ -59,16 +60,9 @@ module Colorable
59
60
  at
60
61
  end
61
62
 
62
- def last(n=1)
63
- @colorset.last(n)
64
- end
65
-
66
- def first(n=1)
67
- @colorset.first(n)
68
- end
69
-
70
63
  def find_index(color)
71
- @colorset.find_index { |c| c == color }
64
+ idx = @colorset.find_index { |c| c == color }
65
+ (@pos+idx)%size if idx
72
66
  end
73
67
 
74
68
  def sort_by(&blk)
@@ -79,10 +73,6 @@ module Colorable
79
73
  self.class.new @colorset.reverse
80
74
  end
81
75
 
82
- def to_a
83
- @colorset
84
- end
85
-
86
76
  def to_s
87
77
  "#<%s %d/%d pos='%s:%s'>" % [:Colorset, @pos, size, at.name, at]
88
78
  end
@@ -1,3 +1,3 @@
1
1
  module Colorable
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -13,13 +13,13 @@ describe Colorable::Colorset do
13
13
  context "when :rgb passed" do
14
14
  before(:all) { @cs = colorset[:rgb] }
15
15
  it { @cs.take(3).map(&:to_s).should eql ['rgb(0,0,0)', 'rgb(0,0,128)', 'rgb(0,0,139)'] }
16
- it { @cs.last.map(&:to_s).should eql ['rgb(255,255,255)'] }
16
+ it { @cs.last.to_s.should eql 'rgb(255,255,255)' }
17
17
  end
18
18
 
19
19
  context "when :red" do
20
20
  before(:all) { @cs = colorset[:red] }
21
21
  it { @cs.take(3).map(&:to_s).should eql ['rgb(0,0,0)', 'rgb(0,0,128)', 'rgb(0,0,139)'] }
22
- it { @cs.last.map(&:to_s).should eql ['rgb(255,255,255)'] }
22
+ it { @cs.last.to_s.should eql 'rgb(255,255,255)' }
23
23
  end
24
24
 
25
25
  context "when :green in descent order" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: colorable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - kyoendo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-29 00:00:00.000000000 Z
11
+ date: 2013-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec