Class: Cell

Inherits:
Object
  • Object
show all
Extended by:
Logging
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
@@log =
self.init_logger

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

init_logger, log_level=, log_target=

Methods included from File_Checking

#file_check, file_check

Constructor Details

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

Returns a new instance of Cell.



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/cell.rb', line 38

def initialize(row = nil, col = nil, value = nil)
  @log = @@log
  @row = row if row
  @col = col if col
  @type_class = @@DEF_TYPE
  @value = value
  split_value
  set_limits
  @row.resize
  @log.debug("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.



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

def ideal_height
  @ideal_height
end

#ideal_widthObject (readonly)

Returns the value of attribute ideal_width.



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

def ideal_width
  @ideal_width
end

#valueObject

Returns the value of attribute value.



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

def value
  @value
end

Instance Method Details

#colObject



76
77
78
# File 'lib/cell.rb', line 76

def col
  @col.number
end

#line(num = nil) ⇒ Object



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

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

#resizeObject



62
63
64
65
66
67
# File 'lib/cell.rb', line 62

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

#rowObject



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

def row
  @row.number
end

#to_cellObject



50
51
52
# File 'lib/cell.rb', line 50

def to_cell()
  self
end

#to_sObject



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

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