Class: SLDB::SleepCycle

Inherits:
Object
  • Object
show all
Defined in:
lib/sldb.rb,
lib/sldb-0.2.0.rb

Overview

class ThreadedRefresher

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ SleepCycle

Returns a new instance of SleepCycle.

Raises:

  • (ArgumentError)


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

#incObject (readonly)

Returns the value of attribute inc.



416
417
418
# File 'lib/sldb.rb', line 416

def inc
  @inc
end

#maxObject (readonly)

Returns the value of attribute max.



414
415
416
# File 'lib/sldb.rb', line 414

def max
  @max
end

#minObject (readonly)

–{{{



413
414
415
# File 'lib/sldb.rb', line 413

def min
  @min
end

#rangeObject (readonly)

Returns the value of attribute range.



415
416
417
# File 'lib/sldb.rb', line 415

def range
  @range
end

Instance Method Details

#nextObject

–}}}



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

#resetObject

–}}}



441
442
443
444
445
# File 'lib/sldb.rb', line 441

def reset
#--{{{
  @idx = 0
#--}}}
end