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.
24 25 26 27 28 29 30 |
# File 'lib/parseexcel/parseexcel.rb', line 24 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.
22 23 24 |
# File 'lib/parseexcel/parseexcel.rb', line 22 def annotation @annotation end |
#book ⇒ Object
Returns the value of attribute book.
22 23 24 |
# File 'lib/parseexcel/parseexcel.rb', line 22 def book @book end |
#code ⇒ Object
Returns the value of attribute code.
22 23 24 |
# File 'lib/parseexcel/parseexcel.rb', line 22 def code @code end |
#encoding ⇒ Object
Returns the value of attribute encoding.
22 23 24 |
# File 'lib/parseexcel/parseexcel.rb', line 22 def encoding @encoding end |
#format ⇒ Object
Returns the value of attribute format.
22 23 24 |
# File 'lib/parseexcel/parseexcel.rb', line 22 def format @format end |
#kind ⇒ Object
Returns the value of attribute kind.
22 23 24 |
# File 'lib/parseexcel/parseexcel.rb', line 22 def kind @kind end |
#numeric ⇒ Object
Returns the value of attribute numeric.
22 23 24 |
# File 'lib/parseexcel/parseexcel.rb', line 22 def numeric @numeric end |
#rich ⇒ Object
Returns the value of attribute rich.
22 23 24 |
# File 'lib/parseexcel/parseexcel.rb', line 22 def rich @rich end |
#value ⇒ Object
Returns the value of attribute value.
22 23 24 |
# File 'lib/parseexcel/parseexcel.rb', line 22 def value @value end |
Instance Method Details
#date ⇒ Object
31 32 33 |
# File 'lib/parseexcel/parseexcel.rb', line 31 def date @row.date @idx end |
#datetime ⇒ Object
34 35 36 |
# File 'lib/parseexcel/parseexcel.rb', line 34 def datetime @row.datetime @idx end |
#to_f ⇒ Object
40 41 42 |
# File 'lib/parseexcel/parseexcel.rb', line 40 def to_f @value.to_f end |
#to_i ⇒ Object
37 38 39 |
# File 'lib/parseexcel/parseexcel.rb', line 37 def to_i @value.to_i end |
#to_s(target_encoding = nil) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/parseexcel/parseexcel.rb', line 43 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
54 55 56 57 58 59 60 61 62 |
# File 'lib/parseexcel/parseexcel.rb', line 54 def type if @format && (@format.date? || @format.time?) :date elsif @value.is_a?(Numeric) :numeric else :text end end |