Class: Tablemaker::Node
- Includes:
- Enumerable
- Defined in:
- lib/tablemaker/frame.rb
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
Attributes inherited from Frame
Instance Method Summary collapse
- #cell(*args) ⇒ Object
- #cells ⇒ Object
- #each_row ⇒ Object
-
#initialize(p = nil, idx = nil) {|_self| ... } ⇒ Node
constructor
A new instance of Node.
Methods inherited from Frame
#dimensions, #last?, #real_cols, #real_dimensions, #real_rows
Constructor Details
#initialize(p = nil, idx = nil) {|_self| ... } ⇒ Node
Returns a new instance of Node.
61 62 63 64 65 |
# File 'lib/tablemaker/frame.rb', line 61 def initialize(p=nil, idx = nil) super @items = [] yield self end |
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
58 59 60 |
# File 'lib/tablemaker/frame.rb', line 58 def items @items end |
Instance Method Details
#cell(*args) ⇒ Object
67 68 69 |
# File 'lib/tablemaker/frame.rb', line 67 def cell(*args) Cell.new(self, @items.length, *args).tap { |c| @items << c } end |
#cells ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'lib/tablemaker/frame.rb', line 71 def cells f = Fiber.new do cell_iterator do |i| yield i end nil end f = f.resume while f && f.alive? end |
#each_row ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/tablemaker/frame.rb', line 81 def each_row items = [] f = Fiber.new do cell_iterator do |i| items << i end nil end while f && f.alive? f = f.resume yield items unless items.empty? items = [] end end |