Class: Spreadsheet::ParseExcel::Worksheet::Cell
- Inherits:
-
Object
- Object
- Spreadsheet::ParseExcel::Worksheet::Cell
- Defined in:
- lib/parseexcel/parseexcel.rb
Instance Attribute Summary collapse
-
#annotation ⇒ Object
Returns the value of attribute annotation.
-
#book ⇒ Object
Returns the value of attribute book.
-
#code ⇒ Object
Returns the value of attribute code.
-
#encoding ⇒ Object
Returns the value of attribute encoding.
-
#format ⇒ Object
Returns the value of attribute format.
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#numeric ⇒ Object
Returns the value of attribute numeric.
-
#rich ⇒ Object
Returns the value of attribute rich.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #date ⇒ Object
- #datetime ⇒ Object
-
#initialize(value, format, row, idx) ⇒ Cell
constructor
A new instance of Cell.
- #to_f ⇒ Object
- #to_i ⇒ Object
- #to_s(target_encoding = nil) ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(value, format, row, idx) ⇒ Cell
Returns a new instance of Cell.
25 26 27 28 29 30 31 |
# File 'lib/parseexcel/parseexcel.rb', line 25 def initialize value, format, row, idx @format = format @idx = idx @row = row @value = value @encoding = Spreadsheet.client_encoding end |
Instance Attribute Details
#annotation ⇒ Object
Returns the value of attribute annotation.
23 24 25 |
# File 'lib/parseexcel/parseexcel.rb', line 23 def annotation @annotation end |
#book ⇒ Object
Returns the value of attribute book.
23 24 25 |
# File 'lib/parseexcel/parseexcel.rb', line 23 def book @book end |
#code ⇒ Object
Returns the value of attribute code.
23 24 25 |
# File 'lib/parseexcel/parseexcel.rb', line 23 def code @code end |
#encoding ⇒ Object
Returns the value of attribute encoding.
23 24 25 |
# File 'lib/parseexcel/parseexcel.rb', line 23 def encoding @encoding end |
#format ⇒ Object
Returns the value of attribute format.
23 24 25 |
# File 'lib/parseexcel/parseexcel.rb', line 23 def format @format end |
#kind ⇒ Object
Returns the value of attribute kind.
23 24 25 |
# File 'lib/parseexcel/parseexcel.rb', line 23 def kind @kind end |
#numeric ⇒ Object
Returns the value of attribute numeric.
23 24 25 |
# File 'lib/parseexcel/parseexcel.rb', line 23 def numeric @numeric end |
#rich ⇒ Object
Returns the value of attribute rich.
23 24 25 |
# File 'lib/parseexcel/parseexcel.rb', line 23 def rich @rich end |
#value ⇒ Object
Returns the value of attribute value.
23 24 25 |
# File 'lib/parseexcel/parseexcel.rb', line 23 def value @value end |
Instance Method Details
#date ⇒ Object
33 34 35 |
# File 'lib/parseexcel/parseexcel.rb', line 33 def date @row.date @idx end |
#datetime ⇒ Object
37 38 39 |
# File 'lib/parseexcel/parseexcel.rb', line 37 def datetime @row.datetime @idx end |
#to_f ⇒ Object
45 46 47 |
# File 'lib/parseexcel/parseexcel.rb', line 45 def to_f @value.to_f end |
#to_i ⇒ Object
41 42 43 |
# File 'lib/parseexcel/parseexcel.rb', line 41 def to_i @value.to_i end |
#to_s(target_encoding = nil) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/parseexcel/parseexcel.rb', line 49 def to_s(target_encoding = nil) if target_encoding begin Iconv.new(target_encoding, @encoding).iconv(@value) rescue Iconv.new(target_encoding, "ascii").iconv(@value.to_s) end else @value.to_s end end |
#type ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/parseexcel/parseexcel.rb', line 61 def type if @format && (@format.date? || @format.time?) :date elsif @value.is_a?(Numeric) :numeric else :text end end |