jacobat-cyclic 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/cyclic.rb +7 -1
  2. data/test/test_cyclic.rb +6 -0
  3. metadata +1 -1
data/lib/cyclic.rb CHANGED
@@ -2,9 +2,11 @@ $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
4
  module Cyclic
5
- VERSION = '0.0.1'
5
+ VERSION = '0.0.2'
6
6
 
7
7
  class Buffer
8
+ include Enumerable
9
+
8
10
  def initialize(size)
9
11
  @size = size
10
12
  @buffer = []
@@ -20,6 +22,10 @@ module Cyclic
20
22
  def read
21
23
  @buffer
22
24
  end
25
+
26
+ def each(&blk)
27
+ @buffer.each(&blk)
28
+ end
23
29
  end
24
30
  end
25
31
 
data/test/test_cyclic.rb CHANGED
@@ -52,4 +52,10 @@ class TestCyclic < Test::Unit::TestCase
52
52
  end
53
53
  assert_equal(words[1,5], @buffer.read)
54
54
  end
55
+
56
+ def test_should_be_enumerable
57
+ @buffer.push(*(1..5).to_a)
58
+ actual = @buffer.map{|e| e + 1 }
59
+ assert_equal((2..6).to_a, actual)
60
+ end
55
61
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jacobat-cyclic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Atzen