Class: Bart::Estimate

Inherits:
Object
  • Object
show all
Defined in:
lib/bart/estimate.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ Estimate

Returns a new instance of Estimate.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/bart/estimate.rb', line 8

def initialize(xml)
  document = Nokogiri::XML.parse(xml)

  @minutes   = document.css('minutes').text.to_i
  @platform  = document.css('platform').text.to_i
  @direction = document.css('direction').text
  @length    = document.css('length').text.to_i
  @color     = document.css('color').text
  @hexcolor  = document.css('hexcolor').text
  @bikeflag  = document.css('bikeflag').text.to_i == 1
end

Instance Attribute Details

#bikeflagObject (readonly)

Returns the value of attribute bikeflag.



6
7
8
# File 'lib/bart/estimate.rb', line 6

def bikeflag
  @bikeflag
end

#colorObject (readonly)

Returns the value of attribute color.



6
7
8
# File 'lib/bart/estimate.rb', line 6

def color
  @color
end

#directionObject (readonly)

Returns the value of attribute direction.



6
7
8
# File 'lib/bart/estimate.rb', line 6

def direction
  @direction
end

#hexcolorObject (readonly)

Returns the value of attribute hexcolor.



6
7
8
# File 'lib/bart/estimate.rb', line 6

def hexcolor
  @hexcolor
end

#lengthObject (readonly)

Returns the value of attribute length.



6
7
8
# File 'lib/bart/estimate.rb', line 6

def length
  @length
end

#minutesObject (readonly)

Returns the value of attribute minutes.



6
7
8
# File 'lib/bart/estimate.rb', line 6

def minutes
  @minutes
end

#platformObject (readonly)

Returns the value of attribute platform.



6
7
8
# File 'lib/bart/estimate.rb', line 6

def platform
  @platform
end

Instance Method Details

#secondsObject



20
21
22
# File 'lib/bart/estimate.rb', line 20

def seconds
  @minutes * 60
end

#timeObject



24
25
26
# File 'lib/bart/estimate.rb', line 24

def time
  Time.now + seconds
end