Class: Roo::Excelx::Cell::Time
- Defined in:
- lib/roo/excelx/cell/time.rb
Instance Attribute Summary collapse
-
#cell_value ⇒ Object
readonly
Returns the value of attribute cell_value.
-
#coordinate ⇒ Object
readonly
Returns the value of attribute coordinate.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#formula ⇒ Object
readonly
Returns the value of attribute formula.
-
#link ⇒ Object
readonly
Returns the value of attribute link.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes inherited from Base
Instance Method Summary collapse
- #formatted_value ⇒ Object (also: #to_s)
-
#initialize(value, formula, excelx_type, style, link, base_date, coordinate) ⇒ Time
constructor
A new instance of Time.
Methods inherited from Base
#empty?, #excelx_type, #excelx_value, #formula?, #hyperlink, #link?, #type
Constructor Details
#initialize(value, formula, excelx_type, style, link, base_date, coordinate) ⇒ Time
Returns a new instance of Time.
9 10 11 12 13 14 15 16 |
# File 'lib/roo/excelx/cell/time.rb', line 9 def initialize(value, formula, excelx_type, style, link, base_date, coordinate) # NOTE: Pass all arguments to DateTime super class. super @type = :time @format = excelx_type.last @datetime = create_datetime(base_date, value) @value = link? ? Roo::Link.new(link, value) : (value.to_f * 86_400).to_i end |
Instance Attribute Details
#cell_value ⇒ Object (readonly)
Returns the value of attribute cell_value.
7 8 9 |
# File 'lib/roo/excelx/cell/time.rb', line 7 def cell_value @cell_value end |
#coordinate ⇒ Object (readonly)
Returns the value of attribute coordinate.
7 8 9 |
# File 'lib/roo/excelx/cell/time.rb', line 7 def coordinate @coordinate end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
7 8 9 |
# File 'lib/roo/excelx/cell/time.rb', line 7 def format @format end |
#formula ⇒ Object (readonly)
Returns the value of attribute formula.
7 8 9 |
# File 'lib/roo/excelx/cell/time.rb', line 7 def formula @formula end |
#link ⇒ Object (readonly)
Returns the value of attribute link.
7 8 9 |
# File 'lib/roo/excelx/cell/time.rb', line 7 def link @link end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
7 8 9 |
# File 'lib/roo/excelx/cell/time.rb', line 7 def value @value end |
Instance Method Details
#formatted_value ⇒ Object Also known as: to_s
18 19 20 21 |
# File 'lib/roo/excelx/cell/time.rb', line 18 def formatted_value formatter = @format.gsub(/#{TIME_FORMATS.keys.join('|')}/, TIME_FORMATS) @datetime.strftime(formatter) end |