class Row
Objects of this class represent rows in a spreadsheet table
Attributes
cells[R]
height[R]
number[R]
Public Class Methods
new(number = nil)
click to toggle source
# File lib/row.rb, line 32 def initialize(number = nil) @log = @@log @number = number @cells = Array.new @height = 1 end
Public Instance Methods
add(cell)
click to toggle source
# File lib/row.rb, line 39 def add(cell) n_cell = nil if cell.respond_to?(:to_cell) n_cell = cell elsif cell.respond_to?(:to_i) n_cell = Cell.new(@number, cell) else msg = 'For a new cell, a colum-number must be specified' @log.error(red(msg)) raise StandardError(msg) end @cells.insert(n_cell.col, n_cell) @cells.compact! resize() end
Also aliased as: <<
each() { |c| ... }
click to toggle source
# File lib/row.rb, line 55 def each(&b) @cells.each do |c| yield(c) end end
resize()
click to toggle source
# File lib/row.rb, line 61 def resize() if(@cells && ! @cells.empty? ) if(@cells.length == 1 ) @ideal_height = @cells[0].ideal_height else @ideal_height = @cells.max{|c1, c2| c1.ideal_height <=> c2.ideal_height}.ideal_height end @height = @ideal_height end @height ||= @@DEF_HEIGHT end
to_s()
click to toggle source
# File lib/row.rb, line 73 def to_s '#<' << self.class.name << ':' << object_id.to_s << "{number=%s height=%s cells.length=%s}" %[@number.to_s, @height.to_s, @cells.length.to_s] end