Class: Rspreadsheet::Cell
- Inherits:
-
Object
- Object
- Rspreadsheet::Cell
- Defined in:
- lib/rspreadsheet/cell.rb
Instance Attribute Summary collapse
-
#col ⇒ Object
readonly
Returns the value of attribute col.
-
#row ⇒ Object
readonly
Returns the value of attribute row.
-
#source_node ⇒ Object
readonly
Returns the value of attribute source_node.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #coordinates ⇒ Object
-
#initialize(arow, acol, source_node = nil) ⇒ Cell
constructor
A new instance of Cell.
- #to_s ⇒ Object
Constructor Details
#initialize(arow, acol, source_node = nil) ⇒ Cell
Returns a new instance of Cell.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rspreadsheet/cell.rb', line 6 def initialize(arow,acol,source_node=nil) @col = acol @row = arow @source_node = source_node unless @source_node.nil? @type = @source_node.attributes['value-type'].to_s if (@source_node.children.size == 0) and (not @source_node.attributes?) @value = nil else # here you also ned to read style not only value @value = case @type when 'float' @source_node.attributes['value'].to_f when 'string' @source_node.elements.first.andand.content.to_s when 'date' Date.strptime(@source_node.attributes['date-value'].to_s, '%Y-%m-%d') when 'percentage' @source_node.attributes['value'].to_f else if @source_node.children.size == 0 nil else nil # raise "Unknown type from #{@source_node.to_s} / children size=#{@source_node.children.size.to_s} / type=#{@type}" end end end end end |
Instance Attribute Details
#col ⇒ Object (readonly)
Returns the value of attribute col.
5 6 7 |
# File 'lib/rspreadsheet/cell.rb', line 5 def col @col end |
#row ⇒ Object (readonly)
Returns the value of attribute row.
5 6 7 |
# File 'lib/rspreadsheet/cell.rb', line 5 def row @row end |
#source_node ⇒ Object (readonly)
Returns the value of attribute source_node.
5 6 7 |
# File 'lib/rspreadsheet/cell.rb', line 5 def source_node @source_node end |
#value ⇒ Object
Returns the value of attribute value.
5 6 7 |
# File 'lib/rspreadsheet/cell.rb', line 5 def value @value end |
Instance Method Details
#coordinates ⇒ Object
43 44 45 |
# File 'lib/rspreadsheet/cell.rb', line 43 def coordinates [row,col] end |
#to_s ⇒ Object
36 37 38 |
# File 'lib/rspreadsheet/cell.rb', line 36 def to_s value end |