Class: XlsFunction::Converters::TimeSerialConverter::TimeSerial
- Inherits:
-
Object
- Object
- XlsFunction::Converters::TimeSerialConverter::TimeSerial
- Defined in:
- lib/xls_function/converters/time_serial_converter.rb
Instance Attribute Summary collapse
-
#serial ⇒ Object
readonly
Returns the value of attribute serial.
Instance Method Summary collapse
- #hour ⇒ Object
-
#initialize(serial) ⇒ TimeSerial
constructor
A new instance of TimeSerial.
- #millisecond ⇒ Object
- #minute ⇒ Object
- #second ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(serial) ⇒ TimeSerial
Returns a new instance of TimeSerial.
49 50 51 |
# File 'lib/xls_function/converters/time_serial_converter.rb', line 49 def initialize(serial) @serial = serial.frac end |
Instance Attribute Details
#serial ⇒ Object (readonly)
Returns the value of attribute serial.
47 48 49 |
# File 'lib/xls_function/converters/time_serial_converter.rb', line 47 def serial @serial end |
Instance Method Details
#hour ⇒ Object
53 54 55 |
# File 'lib/xls_function/converters/time_serial_converter.rb', line 53 def hour @hour ||= (serial / H_UNIT).round(15).to_i end |
#millisecond ⇒ Object
65 66 67 |
# File 'lib/xls_function/converters/time_serial_converter.rb', line 65 def millisecond @millisecond ||= (without_hour_and_minute_and_second / MS_UNIT).round(15).to_i end |
#minute ⇒ Object
57 58 59 |
# File 'lib/xls_function/converters/time_serial_converter.rb', line 57 def minute @minute ||= (without_hour / M_UNIT).round(15).to_i end |
#second ⇒ Object
61 62 63 |
# File 'lib/xls_function/converters/time_serial_converter.rb', line 61 def second @second ||= (without_hour_and_minute / S_UNIT).round(15).to_i end |
#to_s ⇒ Object
69 70 71 |
# File 'lib/xls_function/converters/time_serial_converter.rb', line 69 def to_s "#{pad_zero(&:hour)}:#{pad_zero(&:minute)}:#{pad_zero(&:second)}#{millisecond_suffix}" end |