Class: Bart::Etd
- Inherits:
-
Object
- Object
- Bart::Etd
- Defined in:
- lib/bart/etd.rb
Instance Attribute Summary collapse
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#estimates ⇒ Object
readonly
Returns the value of attribute estimates.
Instance Method Summary collapse
-
#initialize(xml) ⇒ Etd
constructor
A new instance of Etd.
- #to_s ⇒ Object
Constructor Details
#initialize(xml) ⇒ Etd
Returns a new instance of Etd.
9 10 11 12 13 14 15 16 |
# File 'lib/bart/etd.rb', line 9 def initialize(xml) document = Nokogiri::XML.parse(xml) abbr = document.css('abbreviation').text estimates = document.css('estimate') @destination = Station.new(abbr: abbr) @estimates = estimates.inject([]) { |memo, i| memo << Estimate.new(i.to_s) } end |
Instance Attribute Details
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
7 8 9 |
# File 'lib/bart/etd.rb', line 7 def destination @destination end |
#estimates ⇒ Object (readonly)
Returns the value of attribute estimates.
7 8 9 |
# File 'lib/bart/etd.rb', line 7 def estimates @estimates end |
Instance Method Details
#to_s ⇒ Object
18 19 20 |
# File 'lib/bart/etd.rb', line 18 def to_s "#{destination.name} #{estimates.map(&:minutes) * ', '}" end |