Class: Ruck::Shred
Instance Attribute Summary collapse
-
#finished ⇒ Object
Returns the value of attribute finished.
-
#now ⇒ Object
Returns the value of attribute now.
Instance Method Summary collapse
-
#<=>(shred) ⇒ Object
shreds sort in order of position in time.
- #finish ⇒ Object
- #go(resume) ⇒ Object
-
#initialize(shreduler, now, name, &block) ⇒ Shred
constructor
A new instance of Shred.
- #to_s ⇒ Object
- #yield(samples) ⇒ Object
Constructor Details
#initialize(shreduler, now, name, &block) ⇒ Shred
Returns a new instance of Shred.
8 9 10 11 12 13 14 |
# File 'lib/ruck/shreduling.rb', line 8 def initialize(shreduler, now, name, &block) @shreduler = shreduler @now = now @name = name @block = block @finished = false end |
Instance Attribute Details
#finished ⇒ Object
Returns the value of attribute finished.
6 7 8 |
# File 'lib/ruck/shreduling.rb', line 6 def finished @finished end |
#now ⇒ Object
Returns the value of attribute now.
5 6 7 |
# File 'lib/ruck/shreduling.rb', line 5 def now @now end |
Instance Method Details
#<=>(shred) ⇒ Object
shreds sort in order of position in time
48 49 50 |
# File 'lib/ruck/shreduling.rb', line 48 def <=>(shred) @now <=> shred.now end |
#finish ⇒ Object
43 44 45 |
# File 'lib/ruck/shreduling.rb', line 43 def finish @resume.call # last save point end |
#go(resume) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ruck/shreduling.rb', line 16 def go(resume) @resume = resume # TODO # I don't think this is the right place to catch errors. # I've read the strangest memory errors after an exception # is caught here; I have a feeling exceptions ought to be # caught within the continuation itself. begin @block.call self rescue => e LOG.error "#{self} exited uncleanly:\n#{e}\n#{e.backtrace}" end @finished = true end |
#to_s ⇒ Object
52 53 54 |
# File 'lib/ruck/shreduling.rb', line 52 def to_s "<Shred: #{@name}>" end |