class XfOOrth::XfOOrth_Bundle
The fOOrth Bundle class. A bundle contains multiple fibers.
Public Class Methods
new(fibers=[])
click to toggle source
Build up the bundle instance
# File lib/fOOrth/library/bundle_library.rb, line 13 def initialize(fibers=[]) @fibers = fibers.in_array.map {|fiber| fiber.to_foorth_fiber} @current = 0 rescue NoMethodError error "F70: A bundle may only contain procedures, fibers, or bundles." end
Public Instance Methods
add_fibers(fibers)
click to toggle source
Add the fibers to this bundle.
# File lib/fOOrth/library/bundle_library.rb, line 21 def add_fibers(fibers) fibers.in_array.each {|fiber| @fibers << fiber.to_foorth_fiber} rescue NoMethodError error "F70: A bundle may only contain procedures, fibers, or bundles." end
length()
click to toggle source
how many fibers in this bundle?
# File lib/fOOrth/library/bundle_library.rb, line 38 def length @fibers.length end
run(vm)
click to toggle source
Run the fiber bundle constantly until done.
# File lib/fOOrth/library/bundle_library.rb, line 59 def run(vm) while step(vm); end end
status()
click to toggle source
What is the status of this bundle?
# File lib/fOOrth/library/bundle_library.rb, line 33 def status @fibers.empty? ? "dead" : "alive" end
step(vm)
click to toggle source
Let the fiber run for one step
Endemic Code Smells
-
:reek:DuplicateMethodCall
# File lib/fOOrth/library/bundle_library.rb, line 45 def step(vm) if @current < @fibers.length if @fibers[@current].step(vm) @current += 1 else @fibers.delete_at(@current) end end @current = 0 unless @current < @fibers.length !@fibers.empty? end
to_foorth_fiber()
click to toggle source
Return this bundle as a fiber.
# File lib/fOOrth/library/bundle_library.rb, line 28 def to_foorth_fiber self end