Class: XlsFunction::Converters::TimeSerialConverter::TimeSerial

Inherits:
Object
  • Object
show all
Defined in:
lib/xls_function/converters/time_serial_converter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#serialObject (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

#hourObject



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

#millisecondObject



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

#minuteObject



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

#secondObject



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_sObject



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