Class: SLDB::SleepCycle
- Inherits:
-
Object
- Object
- SLDB::SleepCycle
- Defined in:
- lib/sldb.rb,
lib/sldb-0.2.0.rb
Overview
class ThreadedRefresher
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(*args) ⇒ SleepCycle
constructor
A new instance of SleepCycle.
-
#next ⇒ Object
–}}}.
-
#reset ⇒ Object
–}}}.
Constructor Details
#initialize(*args) ⇒ SleepCycle
Returns a new instance of SleepCycle.
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 |
# File 'lib/sldb.rb', line 417 def initialize(*args) #--{{{ min, max, inc = args.flatten raise ArgumentError, 'no min' unless min raise ArgumentError, 'no max' unless max raise ArgumentError, 'no inc' unless inc @min, @max, @inc = Float(min), Float(max), Float(inc) @range = @max - @min raise RangeError, "max < min" if @max < @min raise RangeError, "inc > range" if @inc > @range @list = [] s = @min @list.push(s) and s += @inc while(s <= @max) @list[-1] = @max if @list[-1] < @max reset #--}}} end |
Instance Attribute Details
#inc ⇒ Object (readonly)
Returns the value of attribute inc.
416 417 418 |
# File 'lib/sldb.rb', line 416 def inc @inc end |
#max ⇒ Object (readonly)
Returns the value of attribute max.
414 415 416 |
# File 'lib/sldb.rb', line 414 def max @max end |
#min ⇒ Object (readonly)
–{{{
413 414 415 |
# File 'lib/sldb.rb', line 413 def min @min end |
#range ⇒ Object (readonly)
Returns the value of attribute range.
415 416 417 |
# File 'lib/sldb.rb', line 415 def range @range end |
Instance Method Details
#next ⇒ Object
–}}}
434 435 436 437 438 439 440 |
# File 'lib/sldb.rb', line 434 def next #--{{{ ret = @list[@idx] @idx = ((@idx + 1) % @list.size) ret #--}}} end |
#reset ⇒ Object
–}}}
441 442 443 444 445 |
# File 'lib/sldb.rb', line 441 def reset #--{{{ @idx = 0 #--}}} end |