Class: Lockfile::SleepCycle
- Defined in:
- lib/gems/lockfile-1.4.3/lib/lockfile.rb,
lib/gems/lockfile-1.4.3/lib/lockfile-1.4.3.rb
Constant Summary
Constants included from Diff::LCS
Diff::LCS::BalancedCallbacks, Diff::LCS::PATCH_MAP, Diff::LCS::SequenceCallbacks, Diff::LCS::VERSION
Instance Attribute Summary collapse
-
#inc ⇒ Object
readonly
Returns the value of attribute inc.
-
#max ⇒ Object
readonly
Returns the value of attribute max.
-
#min ⇒ Object
readonly
–{{{.
-
#range ⇒ Object
readonly
Returns the value of attribute range.
Instance Method Summary collapse
-
#initialize(min, max, inc) ⇒ SleepCycle
constructor
A new instance of SleepCycle.
-
#next ⇒ Object
–}}}.
-
#reset ⇒ Object
–}}}.
Methods included from Diff::LCS
LCS, __diff_direction, __inverse_vector, __lcs, __normalize_patchset, __position_hash, __replace_next_larger, diff, #diff, #lcs, patch, #patch, #patch!, patch!, sdiff, #sdiff, traverse_balanced, #traverse_balanced, traverse_sequences, #traverse_sequences, #unpatch, #unpatch!, unpatch!
Constructor Details
#initialize(min, max, inc) ⇒ SleepCycle
Returns a new instance of SleepCycle.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/gems/lockfile-1.4.3/lib/lockfile.rb', line 27 def initialize min, max, inc #--{{{ @min, @max, @inc = Float(min), Float(max), Float(inc) @range = @max - @min raise RangeError, "max(#{ @max }) <= min(#{ @min })" if @max <= @min raise RangeError, "inc(#{ @inc }) > range(#{ @range })" if @inc > @range raise RangeError, "inc(#{ @inc }) <= 0" if @inc <= 0 raise RangeError, "range(#{ @range }) <= 0" if @range <= 0 s = @min push(s) and s += @inc while(s <= @max) self[-1] = @max if self[-1] < @max reset #--}}} end |
Instance Attribute Details
#inc ⇒ Object (readonly)
Returns the value of attribute inc.
26 27 28 |
# File 'lib/gems/lockfile-1.4.3/lib/lockfile.rb', line 26 def inc @inc end |
#max ⇒ Object (readonly)
Returns the value of attribute max.
24 25 26 |
# File 'lib/gems/lockfile-1.4.3/lib/lockfile.rb', line 24 def max @max end |
#min ⇒ Object (readonly)
–{{{
23 24 25 |
# File 'lib/gems/lockfile-1.4.3/lib/lockfile.rb', line 23 def min @min end |
#range ⇒ Object (readonly)
Returns the value of attribute range.
25 26 27 |
# File 'lib/gems/lockfile-1.4.3/lib/lockfile.rb', line 25 def range @range end |
Instance Method Details
#next ⇒ Object
–}}}
41 42 43 44 45 46 47 |
# File 'lib/gems/lockfile-1.4.3/lib/lockfile.rb', line 41 def next #--{{{ ret = self[@idx] @idx = ((@idx + 1) % self.size) ret #--}}} end |
#reset ⇒ Object
–}}}
48 49 50 51 52 |
# File 'lib/gems/lockfile-1.4.3/lib/lockfile.rb', line 48 def reset #--{{{ @idx = 0 #--}}} end |