Class: IRail::MIVBSTIB::JSONParser

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

Constant Summary collapse

STATIONS_KEY =
"Stations"

Class Method Summary collapse

Class Method Details

.parse_stations(json_string) ⇒ Object



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

def self.parse_stations(json_string)
  json_hash      = JSON.parse(json_string)
  stations_json  = json_hash[STATIONS_KEY]
  stations_json.inject([]) do |stations, station_attributes|
    stations << IRail::MIVBSTIB::Station.new(station_attributes)
  end
end