juncture 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d6d2a7c30fe31a9d2546027a5d54c7e9408cb3c3
4
- data.tar.gz: 30cbde17db14053e6b988e6a4ffb1beba2e4c217
3
+ metadata.gz: 61b996b0d6978fb289c9febfb3e9b847d07b5d0a
4
+ data.tar.gz: f8c9a2bbded8d77c3b4c77df3efdc7b830806066
5
5
  SHA512:
6
- metadata.gz: a7df57354b19319d741bb27280d313a810d4776cbb84ea693255ab8bb0d6306614bffa973f2baaf8ffd45488e864668fe8685494dfe2563a1ff8002fb784ddba
7
- data.tar.gz: 19722144048c8d7223b2b30cafe0b79be4bad11bfc953566223127afbd04563f6a28c9c305375a639569376c4951edcaa448fd79392db1bfee24d8f72ba75b82
6
+ metadata.gz: 86aece69ac367895594029e69211559472e235175bc40ad8acd931440a962782d6143e410d8236059c780ea087447063f6a8b6a8cd9fc035a266604a0db2389e
7
+ data.tar.gz: e5b85b56992a3e2bee953f026946c9329172784504d45e19384ae5fd722e28e88df92b809105732b72db1a5029e532b67a00e87a68726fe4587903f047a5f5e8
data/lib/juncture.rb CHANGED
@@ -25,6 +25,14 @@ class Juncture
25
25
  @current_state = new_state
26
26
  end
27
27
 
28
+ def next
29
+ if index.nil? || @states[index+1].nil?
30
+ @current_state = @states[0]
31
+ else
32
+ @current_state = @states[index+1]
33
+ end
34
+ end
35
+
28
36
  def ==(value)
29
37
  @current_state == value
30
38
  end
@@ -1,4 +1,4 @@
1
1
  class Juncture
2
- VERSION = "0.1.0".freeze
2
+ VERSION = "0.1.1".freeze
3
3
  DATE = "2014-02-04".freeze
4
4
  end
@@ -42,6 +42,40 @@ describe Juncture do
42
42
  end
43
43
  end
44
44
 
45
+ describe '#next' do
46
+ it 'moves the state forward one step' do
47
+ temp = Juncture.new 1, 2, 3, default: 1
48
+ expect(temp.next).to eq 2
49
+ expect(temp.state).to eq 2
50
+ expect(temp.next).to eq 3
51
+ expect(temp.state).to eq 3
52
+ end
53
+
54
+ it 'resets if on final state' do
55
+ temp = Juncture.new 1, 2, 3, default: 2
56
+ expect(temp.next).to eq 3
57
+ expect(temp.state).to eq 3
58
+ expect(temp.next).to eq 1
59
+ expect(temp.state).to eq 1
60
+ end
61
+
62
+ it 'resets if default is nil' do
63
+ temp = Juncture.new 1, 2, 3
64
+ expect(temp.next).to eq 1
65
+ expect(temp.state).to eq 1
66
+ expect(temp.next).to eq 2
67
+ expect(temp.state).to eq 2
68
+ end
69
+
70
+ it 'resets if default is not a state' do
71
+ temp = Juncture.new 1, 2, 3, default: 4
72
+ expect(temp.next).to eq 1
73
+ expect(temp.state).to eq 1
74
+ expect(temp.next).to eq 2
75
+ expect(temp.state).to eq 2
76
+ end
77
+ end
78
+
45
79
  describe '#==' do
46
80
  it 'returns true if matching' do
47
81
  temp = Juncture.new 1, 2, 3, default: 2
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: juncture
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Slaughter