Class: Tablemaker::Row

Inherits:
Node show all
Defined in:
lib/tablemaker/frame.rb

Instance Attribute Summary

Attributes inherited from Node

#items

Attributes inherited from Frame

#parent

Instance Method Summary collapse

Methods inherited from Node

#cell, #cells, #each_row, #initialize

Methods inherited from Frame

#dimensions, #initialize, #last?, #real_cols, #real_dimensions, #real_rows

Constructor Details

This class inherits a constructor from Tablemaker::Node

Instance Method Details

#cell_iterator(&blk) ⇒ Object



129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/tablemaker/frame.rb', line 129

def cell_iterator(&blk)
  fibers = @items.map do |i|
    Fiber.new do
      i.cell_iterator(&blk)
    end
  end

  while !fibers.empty?
    fibers = fibers.map { |f| f.resume }.compact
    Fiber.yield(Fiber.current)
  end
end

#column(&blk) ⇒ Object



119
120
121
# File 'lib/tablemaker/frame.rb', line 119

def column(&blk)
  Column.new(self, @items.length, &blk).tap { |c| @items << c }
end

#columnsObject



122
123
124
# File 'lib/tablemaker/frame.rb', line 122

def columns
  @items.map(&:columns).inject(0, &:+)
end

#rowsObject



125
126
127
# File 'lib/tablemaker/frame.rb', line 125

def rows
  @items.map(&:rows).max || 0
end