Class: Timezone::Parser::Line

Inherits:
Object
  • Object
show all
Defined in:
lib/timezone/parser.rb

Constant Summary collapse

SOURCE_FORMAT =
'%a %b %e %H:%M:%S %Y %Z'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(match) ⇒ Line

Returns a new instance of Line.



29
30
31
32
33
34
# File 'lib/timezone/parser.rb', line 29

def initialize(match)
  self.source = Time.strptime(match[1]+'C', SOURCE_FORMAT).to_i
  self.name = match[2].split(' ').last
  self.dst = match[3].to_i
  self.offset = match[4].to_i
end

Instance Attribute Details

#dstObject

Returns the value of attribute dst.



25
26
27
# File 'lib/timezone/parser.rb', line 25

def dst
  @dst
end

#nameObject

Returns the value of attribute name.



25
26
27
# File 'lib/timezone/parser.rb', line 25

def name
  @name
end

#offsetObject

Returns the value of attribute offset.



25
26
27
# File 'lib/timezone/parser.rb', line 25

def offset
  @offset
end

#sourceObject

Returns the value of attribute source.



25
26
27
# File 'lib/timezone/parser.rb', line 25

def source
  @source
end

Instance Method Details

#==(other) ⇒ Object



36
37
38
# File 'lib/timezone/parser.rb', line 36

def ==(other)
  name == other.name && dst == other.dst && offset == other.offset
end

#to_sObject



40
41
42
# File 'lib/timezone/parser.rb', line 40

def to_s
  [source, name, dst, offset].join(':')
end