class Column
Objects of this class represent columns in a spreadsheet table
Constants
- col_width
Attributes
number[R]
width[R]
Public Class Methods
col_width()
click to toggle source
# File lib/column.rb, line 65 def self::col_width @@col_width end
col_width=(w)
click to toggle source
# File lib/column.rb, line 69 def self::col_width=(w) @@col_width = w @log.debug("self::col_width=(#{w}), calling resize") @@columns.each {|col| col.resize(w)} end
new(number = nil)
click to toggle source
# File lib/column.rb, line 35 def initialize(number = nil) @log = @@log @number = number @cells = Array.new @width = @@col_width @@columns << self end
Public Instance Methods
add(cell)
click to toggle source
# File lib/column.rb, line 43 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( cell, @number) else msg = 'For a new cell, a row-number must be specified' @log.error(yellow(msg)) raise StandardError(msg) end @cells.insert(n_cell.row, n_cell) @cells.compact! set_limits end
Also aliased as: <<
each() { |c| ... }
click to toggle source
# File lib/column.rb, line 59 def each(&b) @cells.each do |c| yield(c) end end
resize(width)
click to toggle source
# File lib/column.rb, line 76 def resize(width) @width = width @log.debug('calling resize') @cells.each {|cell| cell.resize} end
to_s()
click to toggle source
# File lib/column.rb, line 82 def to_s '<' << self.class.name.dup << ':' << object_id.to_s << "{number=%s width=%s cells.length=}>" %[@number, @cells.length] end
Private Instance Methods
set_limits()
click to toggle source
# File lib/column.rb, line 91 def set_limits @ideal_width = @cells.max{|c1, c2| c1.ideal_width <=> c2.ideal_width}.ideal_width @ideal_width ||= @@DEF_WIDTH # @width ||= @ideal_width end