Class: Cell

Inherits:
Object
  • Object
show all
Includes:
BasicLogging
Defined in:
lib/cell.rb

Overview

Objects of this class represent cells in a spreadsheet table

Constant Summary collapse

@@DEF_HEIGHT =
1
@@DEF_TYPE =
Integer
@@split_pattern =
nil

Constants included from BasicLogging

BasicLogging::DEBUG, BasicLogging::ERROR, BasicLogging::FATAL, BasicLogging::INFO, BasicLogging::Levels, BasicLogging::UNKNOWN, BasicLogging::WARN

Instance Attribute Summary collapse

Attributes included from BasicLogging

#log_level, #target

Instance Method Summary collapse

Methods included from BasicLogging

is_muted?, #log, mute, #set_level, set_level, set_target, #set_target

Constructor Details

#initialize(row = nil, col = nil, value = nil) ⇒ Cell

create a cell in co:row and enter a value



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/cell.rb', line 30

def initialize(row = nil, col = nil, value = nil)
  @row = row if row
  @col = col if col
  @debinfo = '(' << @col.number.to_s << ':' << @row.number.to_s << ') '
  @type_class = @@DEF_TYPE
  @value = value
  split_value
  set_limits
  @row.resize
  debug(@debinfo << "cell.initialize, lines is #{@lines}, value is #{value}, ideal_width is #{@ideal_width}")
end

Instance Attribute Details

#ideal_heightObject (readonly)

Returns the value of attribute ideal_height.



83
84
85
# File 'lib/cell.rb', line 83

def ideal_height
  @ideal_height
end

#ideal_widthObject (readonly)

Returns the value of attribute ideal_width.



83
84
85
# File 'lib/cell.rb', line 83

def ideal_width
  @ideal_width
end

#valueObject

Returns the value of attribute value.



83
84
85
# File 'lib/cell.rb', line 83

def value
  @value
end

Instance Method Details

#colObject

returns the column number of the cell



74
75
76
# File 'lib/cell.rb', line 74

def col
  @col.number
end

#line(num = nil) ⇒ Object

return a line from the cell



48
49
50
# File 'lib/cell.rb', line 48

def line(num = nil)
  num && num < @lines.length ? @lines[num].to_s : ' ' if @lines && !@lines.empty?
end

#resizeObject

resizes the cell to its ideal value.



58
59
60
61
62
63
# File 'lib/cell.rb', line 58

def resize
  @@split_pattern = nil
  split_value
  set_limits
  @row.resize
end

#rowObject

returns the row number of the cell



79
80
81
# File 'lib/cell.rb', line 79

def row
  @row.number
end

#to_cellObject

returns self



43
44
45
# File 'lib/cell.rb', line 43

def to_cell()
  self
end

#to_sObject

returns a string representation of the cell



53
54
55
# File 'lib/cell.rb', line 53

def to_s
  object_id.to_s << "{" << @row.number.to_s << ":" << @col.number.to_s << ", " << @lines.to_s << ", " << @ideal_height.to_s << ", " << @ideal_width.to_s << " }"
end