Class: Bart::Estimate
- Inherits:
-
Object
- Object
- Bart::Estimate
- Defined in:
- lib/bart/estimate.rb
Instance Attribute Summary collapse
-
#bikeflag ⇒ Object
readonly
Returns the value of attribute bikeflag.
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#direction ⇒ Object
readonly
Returns the value of attribute direction.
-
#hexcolor ⇒ Object
readonly
Returns the value of attribute hexcolor.
-
#length ⇒ Object
readonly
Returns the value of attribute length.
-
#minutes ⇒ Object
readonly
Returns the value of attribute minutes.
-
#platform ⇒ Object
readonly
Returns the value of attribute platform.
Instance Method Summary collapse
-
#initialize(xml) ⇒ Estimate
constructor
A new instance of Estimate.
- #seconds ⇒ Object
- #time ⇒ Object
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
#bikeflag ⇒ Object (readonly)
Returns the value of attribute bikeflag.
6 7 8 |
# File 'lib/bart/estimate.rb', line 6 def bikeflag @bikeflag end |
#color ⇒ Object (readonly)
Returns the value of attribute color.
6 7 8 |
# File 'lib/bart/estimate.rb', line 6 def color @color end |
#direction ⇒ Object (readonly)
Returns the value of attribute direction.
6 7 8 |
# File 'lib/bart/estimate.rb', line 6 def direction @direction end |
#hexcolor ⇒ Object (readonly)
Returns the value of attribute hexcolor.
6 7 8 |
# File 'lib/bart/estimate.rb', line 6 def hexcolor @hexcolor end |
#length ⇒ Object (readonly)
Returns the value of attribute length.
6 7 8 |
# File 'lib/bart/estimate.rb', line 6 def length @length end |
#minutes ⇒ Object (readonly)
Returns the value of attribute minutes.
6 7 8 |
# File 'lib/bart/estimate.rb', line 6 def minutes @minutes end |
#platform ⇒ Object (readonly)
Returns the value of attribute platform.
6 7 8 |
# File 'lib/bart/estimate.rb', line 6 def platform @platform end |
Instance Method Details
#seconds ⇒ Object
20 21 22 |
# File 'lib/bart/estimate.rb', line 20 def seconds @minutes * 60 end |
#time ⇒ Object
24 25 26 |
# File 'lib/bart/estimate.rb', line 24 def time Time.now + seconds end |