Class: Column
Overview
Objects of this class represent columns in a spreadsheet table
Constant Summary
collapse
- @@log =
self.init_logger
- @@DEF_WIDTH =
15
- @@col_width =
@@DEF_WIDTH
- @@columns =
Array.new
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Logging
init_logger, log_level=, log_target=
#file_check, file_check
Constructor Details
#initialize(number = nil) ⇒ Column
Returns a new instance of Column.
35
36
37
38
39
40
41
|
# File 'lib/column.rb', line 35
def initialize(number = nil)
@log = @@log
@number = number
@cells = Array.new
@width = @@col_width
@@columns << self
end
|
Instance Attribute Details
#number ⇒ Object
Returns the value of attribute number.
86
87
88
|
# File 'lib/column.rb', line 86
def number
@number
end
|
#width ⇒ Object
Returns the value of attribute width.
86
87
88
|
# File 'lib/column.rb', line 86
def width
@width
end
|
Class Method Details
.col_width ⇒ Object
65
66
67
|
# File 'lib/column.rb', line 65
def self::col_width
@@col_width
end
|
.col_width=(w) ⇒ Object
69
70
71
72
73
74
|
# 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
|
Instance Method Details
#add(cell) ⇒ Object
Also known as:
<<
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# 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
|
#each(&b) ⇒ Object
59
60
61
62
63
|
# File 'lib/column.rb', line 59
def each(&b)
@cells.each do |c|
yield(c)
end
end
|
#resize(width) ⇒ Object
76
77
78
79
80
|
# File 'lib/column.rb', line 76
def resize(width)
@width = width
@log.debug('calling resize')
@cells.each {|cell| cell.resize}
end
|
#to_s ⇒ Object
82
83
84
|
# 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
|