Class: Timezone::Parser::RefLine
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/timezone/parser.rb |
Overview
Represents a single timezone data file line for a reference timezone.
Class Method Summary
- .new(config, file) ⇒ RefLine constructor
Instance Method Summary
- #to_s
- #parse_offset(offset) private
Constructor Details
.new(config, file) ⇒ RefLine
# File 'lib/timezone/parser.rb', line 48
def initialize(config, file) first = `#{config.zdump} -i #{file}` .split("\n") .reject(&:empty?) .reject { |line| line.start_with?('TZ=') } .first _date, _time, raw_offset, @name = first.split(' ') @offset = parse_offset(raw_offset) end
Instance Method Details
#parse_offset(offset) (private)
[ GitHub ]# File 'lib/timezone/parser.rb', line 66
def parse_offset(offset) arity = offset.start_with?('-') ? -1 : 1 match = offset.match(/^[\-+](\d{2})$/) arity * match[1].to_i * 60 * 60 end
#to_s
[ GitHub ]# File 'lib/timezone/parser.rb', line 60
def to_s "0:#{@name}:0:#{@offset}" end