Class: Ods::Cell
- Inherits:
-
Object
- Object
- Ods::Cell
- Defined in:
- lib/ods/cell.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#row ⇒ Object
readonly
Returns the value of attribute row.
Instance Method Summary collapse
-
#initialize(content, row) ⇒ Cell
constructor
A new instance of Cell.
- #text ⇒ Object
- #value ⇒ Object
Constructor Details
#initialize(content, row) ⇒ Cell
5 6 7 8 |
# File 'lib/ods/cell.rb', line 5 def initialize(content, row) @content = content @row = row end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
3 4 5 |
# File 'lib/ods/cell.rb', line 3 def content @content end |
#row ⇒ Object (readonly)
Returns the value of attribute row.
3 4 5 |
# File 'lib/ods/cell.rb', line 3 def row @row end |
Instance Method Details
#text ⇒ Object
34 35 36 |
# File 'lib/ods/cell.rb', line 34 def text content.text end |
#value ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ods/cell.rb', line 10 def value value_type = content['office:value-type'] #puts "value_type=#{value_type}" case value_type when nil, 'string' text when 'date' Date.strptime(content['office:date-value'], "%Y-%m-%d") when 'boolean' content['office:boolean-value'] == 'true' ? true : false when 'float' str = content['office:value'] if str.match(/\./) str.to_f else str.to_i end when 'percentage' content['office:value'].to_f else warn "Unknown type: #{value_type} [#{text}]" end end |