Class: IRail::MIVBSTIB::DocumentParser

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-irail/packages/mivbstib/parser/document_parser.rb

Constant Summary collapse

STATION_XPATH =
"//Stations"

Class Method Summary collapse

Class Method Details

.parse_stations(xml_string) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/ruby-irail/packages/mivbstib/parser/document_parser.rb', line 5

def self.parse_stations(xml_string)
  xml_payload  = Nokogiri::XML(xml_string)
  xml_stations = xml_payload.xpath(STATION_XPATH)
  xml_stations.inject([]) do |stations, xml_station|
    attributes = IRail::MIVBSTIB::StationParser.parse(xml_station)
    stations << IRail::MIVBSTIB::Station.new(attributes)
  end
end