From 340f5ba18ddd23161c4307821800be03358fc7eb Mon Sep 17 00:00:00 2001 From: Ian Dunlop Date: Fri, 15 Apr 2011 16:38:54 +0100 Subject: [PATCH 1/4] extra code to deal with Manchester GMPTE extras eg ZD, ZS, ZA --- atco.gemspec | 9 ++++-- lib/atco.rb | 77 ++++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 78 insertions(+), 8 deletions(-) diff --git a/atco.gemspec b/atco.gemspec index 3244cc3..3b506c3 100644 --- a/atco.gemspec +++ b/atco.gemspec @@ -8,10 +8,10 @@ Gem::Specification.new do |s| s.version = "0.0.2" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.authors = ["David Rice"] + s.authors = ["David Rice", "Ian Dunlop"] s.date = %q{2010-02-22} s.description = %q{Simple and opinionated library for parsing ATCO-CIF files with Ruby.} - s.email = %q{me@davidjrice.co.uk} + s.email = [%q{me@davidjrice.co.uk}, %q{ianwdunlop@gmail.com}] s.extra_rdoc_files = [ "README.mdown" ] @@ -22,7 +22,10 @@ Gem::Specification.new do |s| "lib/atco.rb", "lib/atco/journey.rb", "lib/atco/location.rb", - "lib/atco/stop.rb" + "lib/atco/stop.rb", + "lib/atco/z_location.rb", + "lib/atco/journey_times.rb", + "lib/atco/journey_route.rb" ] s.homepage = %q{http://github.com/davidjrice/atco} s.rdoc_options = ["--charset=UTF-8"] diff --git a/lib/atco.rb b/lib/atco.rb index 4123855..a058325 100644 --- a/lib/atco.rb +++ b/lib/atco.rb @@ -1,12 +1,11 @@ -$:.unshift(File.dirname(__FILE__)) unless - $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) - require 'open3' require 'tempfile' require 'atco/location' require 'atco/journey' require 'atco/stop' - +require 'atco/journey_route' +require 'atco/journey_times' +require 'atco/z_location' module Atco VERSION = '0.0.1' @@ -25,6 +24,12 @@ class << self :journey_header => 'QS' } + @@gmpte_methods = { + :journey_route => 'ZS', + :stop_location_name => 'ZA', + :journey_times => 'ZD' + } + def parse(file) @path = File.expand_path(file) data = File.readlines(@path) @@ -64,7 +69,39 @@ def parse(file) end end end - return {:header => header, :locations => locations, :journeys => journeys} + + @path = File.expand_path(file) + data = File.readlines(@path) + gmpte_info=[] + record_ended = false + data.each do |line| + case line[0,2] + when 'ZD' + puts 'ZD: ' + line + #this is a gmpte specific thing + #it's a new journey so start again + #the assumption is that the journey record is defined before the stops etc + record_ended = false + z_locations=[] + @journey = JourneyTimes.new(parse_journey_times line) + @journey.z_locations=z_locations + @journey.journey_identifiers = [] + when 'ZA' + #this is a gmpte specific thing + @journey.z_locations << ZLocation.new(parse_stop_location_name line) + when 'ZS' + #this is a gmpte specific thing + @journey.journey_route = JourneyRoute.new(parse_journey_route line) + when 'QS' + journey_info = parse_journey_header(line) + #each journey can have several records due to bank holidays, weekends etc. + @journey.journey_identifiers << journey_info[:unique_journey_identifier] + #That's the end of the record + gmpte_info << @journey unless record_ended + record_ended = true + end + end + return {:header => header, :locations => locations, :journeys => journeys, :gmpte_info=>gmpte_info} end def parse_header(string) @@ -178,6 +215,36 @@ def parse_journey_header(string) def parse_value(value) return value.strip if value end + + #GMPTE has this data + def parse_journey_times(string) + { + :record_identity => string[0,2], + :start_time => string[2,8], + :end_time => string[10,8], + :days_of_the_week_text => parse_value(string[18,48]) + } + end + + #GMPTE has this data + def parse_journey_route(string) + { + :record_identity => string[0,2], + :provider => string[2,8], + :route_name => parse_value(string[10,4]), + :route_text => parse_value(string[14,50]) + } + end + + #GMPTE has this data + def parse_stop_location_name(string) + { + :record_identity => string[0,2], + :type => string[2,1], + :identifier => parse_value(string[3,12]), + :name => parse_value(string[14,48]) + } + end end end \ No newline at end of file From d4c7c815db376ed4a21ddf832f0b4dfcde8160ba Mon Sep 17 00:00:00 2001 From: Ian Dunlop Date: Wed, 20 Apr 2011 17:13:08 +0100 Subject: [PATCH 2/4] changes for the GMPTE codes --- lib/atco.rb | 4 ++-- lib/atco/journey_route.rb | 17 +++++++++++++++++ lib/atco/journey_times.rb | 16 ++++++++++++++++ lib/atco/z_location.rb | 16 ++++++++++++++++ 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 lib/atco/journey_route.rb create mode 100644 lib/atco/journey_times.rb create mode 100644 lib/atco/z_location.rb diff --git a/lib/atco.rb b/lib/atco.rb index a058325..71237bc 100644 --- a/lib/atco.rb +++ b/lib/atco.rb @@ -6,6 +6,7 @@ require 'atco/journey_route' require 'atco/journey_times' require 'atco/z_location' +require 'iconv' module Atco VERSION = '0.0.1' @@ -77,7 +78,6 @@ def parse(file) data.each do |line| case line[0,2] when 'ZD' - puts 'ZD: ' + line #this is a gmpte specific thing #it's a new journey so start again #the assumption is that the journey record is defined before the stops etc @@ -213,7 +213,7 @@ def parse_journey_header(string) end def parse_value(value) - return value.strip if value + return value.strip if value end #GMPTE has this data diff --git a/lib/atco/journey_route.rb b/lib/atco/journey_route.rb new file mode 100644 index 0000000..0976d7f --- /dev/null +++ b/lib/atco/journey_route.rb @@ -0,0 +1,17 @@ +module Atco + + class JourneyRoute + + attr_accessor :record_identity, :provider, :route_name, :route_text + attr_writer :record_identity, :provider, :route_name, :route_text + + def initialize(data) + @record_identity = data[:record_identity] + @provider = data[:provider] + @route_name = data[:route_name] + @route_text = data[:route_text] + end + + end + +end \ No newline at end of file diff --git a/lib/atco/journey_times.rb b/lib/atco/journey_times.rb new file mode 100644 index 0000000..c77ca7d --- /dev/null +++ b/lib/atco/journey_times.rb @@ -0,0 +1,16 @@ +module Atco + + class JourneyTimes + + attr_accessor :journey_identifiers, :record_identity, :start_time, :end_time, :days_of_the_week_text, :z_locations, :journey_route + attr_writer :journey_identifiers, :record_identity, :start_time, :end_time, :days_of_the_week_text, :z_locations, :journey_route + + def initialize(data) + @record_identity = data[:record_identity] + @start_time = data[:start_time] + @days_of_the_week_text = data[:days_of_the_week_text] + @z_locations = data[:z_locations] + @journey_route = data[:journey_route] + end + end +end \ No newline at end of file diff --git a/lib/atco/z_location.rb b/lib/atco/z_location.rb new file mode 100644 index 0000000..feb59a5 --- /dev/null +++ b/lib/atco/z_location.rb @@ -0,0 +1,16 @@ +module Atco + + class ZLocation + + attr_accessor :record_identity, :type, :identifier,:name + attr_writer :record_identity, :type, :identifier,:name + + def initialize(data) + @record_identity = data[:record_identity] + @type = data[:type] + @identifier = data[:identifier] + @name = data[:name] + end + end + +end \ No newline at end of file From b7c1da3c7ac83705a8c621e1bbb2cbc9077cd28c Mon Sep 17 00:00:00 2001 From: Ian Dunlop Date: Mon, 2 May 2011 14:22:46 +0100 Subject: [PATCH 3/4] parse file line by line with case statements. new models --- lib/atco.rb | 200 +++++++++++++++++---------------------- lib/atco/bank_hoilday.rb | 18 ++++ lib/atco/operator.rb | 18 ++++ lib/atco/stop.rb | 3 +- 4 files changed, 124 insertions(+), 115 deletions(-) create mode 100644 lib/atco/bank_hoilday.rb create mode 100644 lib/atco/operator.rb diff --git a/lib/atco.rb b/lib/atco.rb index 71237bc..d8e0871 100644 --- a/lib/atco.rb +++ b/lib/atco.rb @@ -11,70 +11,42 @@ module Atco VERSION = '0.0.1' - class << self - - @path = nil - @@methods = { - :bank_holiday => 'QH', - :operator => 'QP', - :additional_location_info => 'QB', - :location => 'QL', - :destination => 'QT', - :intermediate => 'QI', - :origin => 'QO', - :journey_header => 'QS' - } - - @@gmpte_methods = { - :journey_route => 'ZS', - :stop_location_name => 'ZA', - :journey_times => 'ZD' - } + class Parser def parse(file) - @path = File.expand_path(file) - data = File.readlines(@path) + path = File.expand_path(file) + data = File.readlines(path) - objects = [] - current_journey = nil - current_location = nil - locations = [] - journeys = {} + # locations = [] + journeys = [] header = nil - + journey = nil data.each do |line| - if line == data.first - header = parse_header(line) - next - end - @@methods.each do |method,identifier| - object = self.send("parse_#{method}", line) - if object[:record_identity] && object[:record_identity] == identifier - current_journey = object if object[:record_identity] && object[:record_identity] == @@methods[:journey_header] - if object[:record_identity] && ( object[:record_identity] == @@methods[:location] || object[:record_identity] == @@methods[:additional_location_info] ) - if object[:record_identity] == @@methods[:location] - current_location = object - else - locations << Location.new(current_location, object) - end - end - - if current_journey - if journeys[current_journey[:unique_journey_identifier]] - journeys[current_journey[:unique_journey_identifier]].stops << Stop.new(object) - else - journeys[current_journey[:unique_journey_identifier]] = Journey.new(object) - end - end - objects << object - end + case line[0,2] + when 'QS' + journey = Journey.new(parse_journey_header line) + journeys << journey + when 'QO' + journey.stops << Stop.new(parse_origin line) + when 'QP' + when 'QB' + when 'QL' + when 'QH' + when 'QI' + journey.stops << Stop.new(parse_intermediate line) + when 'QT' + journey.stops << Stop.new(parse_destination line) + when 'QO' end end + # return journeys + # end - @path = File.expand_path(file) - data = File.readlines(@path) + path = File.expand_path(file) + data = File.readlines(path) gmpte_info=[] record_ended = false + journey = nil data.each do |line| case line[0,2] when 'ZD' @@ -83,75 +55,75 @@ def parse(file) #the assumption is that the journey record is defined before the stops etc record_ended = false z_locations=[] - @journey = JourneyTimes.new(parse_journey_times line) - @journey.z_locations=z_locations - @journey.journey_identifiers = [] + journey = JourneyTimes.new(parse_journey_times line) + journey.z_locations=z_locations + journey.journey_identifiers = [] when 'ZA' #this is a gmpte specific thing - @journey.z_locations << ZLocation.new(parse_stop_location_name line) + journey.z_locations << ZLocation.new(parse_stop_location_name line) when 'ZS' #this is a gmpte specific thing - @journey.journey_route = JourneyRoute.new(parse_journey_route line) + journey.journey_route = JourneyRoute.new(parse_journey_route line) when 'QS' journey_info = parse_journey_header(line) #each journey can have several records due to bank holidays, weekends etc. - @journey.journey_identifiers << journey_info[:unique_journey_identifier] + journey.journey_identifiers << journey_info[:unique_journey_identifier] #That's the end of the record - gmpte_info << @journey unless record_ended + gmpte_info << journey unless record_ended record_ended = true end end - return {:header => header, :locations => locations, :journeys => journeys, :gmpte_info=>gmpte_info} - end - - def parse_header(string) - { - :file_type => string[0,8], - :version => "#{string[8,2].to_i}.#{string[10,2].to_i}", - :file_originator => string[12,32].strip!, - :source_product => string[44,16].strip!, - :production_datetime => string[60,14] - } + return {:journeys => journeys, :gmpte_info=>gmpte_info} end - def parse_bank_holiday(string) - { - :record_identity => string[0,2], - :transaction_type => string[2,1], - :date_of_bank_holiday => string[3,8] - } - end - - def parse_operator(string) - { - :record_identity => string[0,2], - :transaction_type => string[2,1], - :operator => parse_value(string[3,4]), - :operator_short_form => parse_value(string[7,24]), - :operator_legal_name => parse_value(string[31,48]) - } - end - - def parse_additional_location_info(string) - { - :record_identity => string[0,2], - :transaction_type => string[2,1], - :location => string[3,12].strip, - :grid_reference_easting => parse_value(string[15,8]), - :grid_reference_northing => parse_value(string[23,8]) - } - end - - def parse_location(string) - { - :record_identity => string[0,2], - :transaction_type => string[2,1], - :location => parse_value(string[3,12]), - :full_location => parse_value(string[15,48]), - :gazetteer_code => string[63,1] - } - end - + # def parse_header(string) + # { + # Journey.new(:file_type => string[0,8], + # :version => "#{string[8,2].to_i}.#{string[10,2].to_i}", + # :file_originator => string[12,32].strip!, + # :source_product => string[44,16].strip!, + # :production_datetime => string[60,14]) + # } + # end + # + # def parse_bank_holiday(string) + # { + # BankHoliday.new(:record_identity => string[0,2], + # :transaction_type => string[2,1], + # :date_of_bank_holiday => string[3,8]) + # } + # end + # + # def parse_operator(string) + # { + # Operator.new(:record_identity => string[0,2], + # :transaction_type => string[2,1], + # :operator => parse_value(string[3,4]), + # :operator_short_form => parse_value(string[7,24]), + # :operator_legal_name => parse_value(string[31,48])) + # } + # end + # + # def parse_additional_location_info(string) + # { + # :record_identity => string[0,2], + # :transaction_type => string[2,1], + # :location => string[3,12].strip, + # :grid_reference_easting => parse_value(string[15,8]), + # :grid_reference_northing => parse_value(string[23,8]) + # } + # end + # + # def parse_location(string) + # { + # :record_identity => string[0,2], + # :transaction_type => string[2,1], + # :location => parse_value(string[3,12]), + # :full_location => parse_value(string[15,48]), + # :gazetteer_code => string[63,1] + # } + # end + # def parse_destination(string) { :record_identity => string[0,2], @@ -162,7 +134,7 @@ def parse_destination(string) :fare_stage_indicator => string[23,2] } end - + def parse_intermediate(string) { :record_identity => string[0,2], @@ -175,7 +147,7 @@ def parse_intermediate(string) :fare_stage_indicator => string[28,2] } end - + def parse_origin(string) { :record_identity => string[0,2], @@ -186,7 +158,7 @@ def parse_origin(string) :fare_stage_indicator => string[23,2] } end - + # def parse_journey_header(string) { :record_identity => string[0,2], @@ -211,7 +183,7 @@ def parse_journey_header(string) :route_direction => string[64,1] } end - + # def parse_value(value) return value.strip if value end diff --git a/lib/atco/bank_hoilday.rb b/lib/atco/bank_hoilday.rb new file mode 100644 index 0000000..d7c6e73 --- /dev/null +++ b/lib/atco/bank_hoilday.rb @@ -0,0 +1,18 @@ +module Atco + + class BankHoliday + :record_identity => string[0,2], + :transaction_type => string[2,1], + :date_of_bank_holiday + attr_accessor :record_identity, :transaction_type, :date_of_bank_holiday + attr_writer :record_identity, :transaction_type, :date_of_bank_holiday + + def initialize(data) + @record_identity = data[:record_identity] + @transaction_type = data[:transaction_type] + @date_of_bank_holiday = data[:date_of_bank_holiday] + end + + end + +end \ No newline at end of file diff --git a/lib/atco/operator.rb b/lib/atco/operator.rb new file mode 100644 index 0000000..b4de139 --- /dev/null +++ b/lib/atco/operator.rb @@ -0,0 +1,18 @@ +module Atco + + class Operator + + attr_accessor :record_identity, :transaction_type, :operator, :operator_short_form, :operator_legal_name + attr_writer :record_identity, :transaction_type, :operator, :operator_short_form, :operator_legal_name + + def initialize(data) + @record_identity = data[:record_identity] + @transaction_type = data[:transaction_type] + @operator = data[:operator] + @operator_short_form = data[:operator_short_form] + @operator_legal_name = data[:operator_legal_name] + end + + end + +end \ No newline at end of file diff --git a/lib/atco/stop.rb b/lib/atco/stop.rb index f38083d..a521486 100644 --- a/lib/atco/stop.rb +++ b/lib/atco/stop.rb @@ -2,7 +2,7 @@ module Atco class Stop - attr_accessor :bay_number, :location, :timing_point_indicator, :fare_stage_indicator, :published_departure_time, :record_identity + attr_accessor :bay_number, :location, :timing_point_indicator, :fare_stage_indicator, :published_arrival_time, :published_departure_time, :record_identity def origin?; @record_identity == "QO"; end def intermediate?; @record_identity == "QI"; end @@ -14,6 +14,7 @@ def initialize(data) @timing_point_indicator = data[:timing_point_indicator] @fare_stage_indicator = data[:fare_stage_indicator] @published_departure_time = data[:published_departure_time] + @published_arrival_time = data[:published_arrival_time] @record_identity = data[:record_identity] end From 711fb54f8b1d36112a9551ddbd3b4dda7c2e854e Mon Sep 17 00:00:00 2001 From: Ian Dunlop Date: Sun, 22 May 2011 20:42:57 +0100 Subject: [PATCH 4/4] parse additional types of records --- atco.gemspec | 4 +- lib/atco.rb | 183 +++++++++++++++++++++----------------- lib/atco/journey_times.rb | 4 +- lib/atco/location.rb | 7 +- lib/atco/operator.rb | 4 +- 5 files changed, 111 insertions(+), 91 deletions(-) diff --git a/atco.gemspec b/atco.gemspec index 3b506c3..8b4d83e 100644 --- a/atco.gemspec +++ b/atco.gemspec @@ -25,7 +25,9 @@ Gem::Specification.new do |s| "lib/atco/stop.rb", "lib/atco/z_location.rb", "lib/atco/journey_times.rb", - "lib/atco/journey_route.rb" + "lib/atco/journey_route.rb", + "lib/atco/header.rb", + "lib/atco/operator.rb" ] s.homepage = %q{http://github.com/davidjrice/atco} s.rdoc_options = ["--charset=UTF-8"] diff --git a/lib/atco.rb b/lib/atco.rb index d8e0871..0cfc3a5 100644 --- a/lib/atco.rb +++ b/lib/atco.rb @@ -6,6 +6,8 @@ require 'atco/journey_route' require 'atco/journey_times' require 'atco/z_location' +require 'atco/operator' +require 'atco/header' require 'iconv' module Atco @@ -17,113 +19,130 @@ def parse(file) path = File.expand_path(file) data = File.readlines(path) - # locations = [] - journeys = [] - header = nil + locations = [] + # journeys = [] journey = nil + header = nil + z_journey = nil + operator = nil + journeys = nil + # locations = [] + operators = [] + gmpte_info=[] + first_line = data.first + header = Header.new(parse_header first_line) data.each do |line| case line[0,2] when 'QS' journey = Journey.new(parse_journey_header line) - journeys << journey + z_journey.journeys << journey when 'QO' journey.stops << Stop.new(parse_origin line) when 'QP' + #operator + operator = Operator.new(parse_operator line) + operators << operator + when 'QQ' + #additional operator info + additional_operator_info = parse_additonal_operator_info line + operator.address = additional_operator_info[:address] when 'QB' + additional_info = parse_additional_location_info(line) + location.easting = additonal_info[:grid_reference_easting] + location.northing = additonal_info[:grid_reference_northing] + location.short_code = additional_info[:location] when 'QL' + location = Location.new(parse_location line) + locations << location + when 'QA' + #alternative location when 'QH' when 'QI' journey.stops << Stop.new(parse_intermediate line) when 'QT' journey.stops << Stop.new(parse_destination line) when 'QO' - end - end - # return journeys - # end - - path = File.expand_path(file) - data = File.readlines(path) - gmpte_info=[] - record_ended = false - journey = nil - data.each do |line| - case line[0,2] - when 'ZD' + when 'QR' + #repetition records + when 'ZD' #this is a gmpte specific thing #it's a new journey so start again #the assumption is that the journey record is defined before the stops etc - record_ended = false + # record_ended = false z_locations=[] - journey = JourneyTimes.new(parse_journey_times line) - journey.z_locations=z_locations - journey.journey_identifiers = [] - when 'ZA' + z_journey = JourneyTimes.new(parse_journey_times line) + z_journey.z_locations=z_locations + z_journey.journey_identifiers = [] + journeys = [] + z_journey.journeys = journeys + gmpte_info << z_journey + when 'ZA' #this is a gmpte specific thing - journey.z_locations << ZLocation.new(parse_stop_location_name line) - when 'ZS' + z_journey.z_locations << ZLocation.new(parse_stop_location_name line) + when 'ZS' #this is a gmpte specific thing - journey.journey_route = JourneyRoute.new(parse_journey_route line) - when 'QS' - journey_info = parse_journey_header(line) - #each journey can have several records due to bank holidays, weekends etc. - journey.journey_identifiers << journey_info[:unique_journey_identifier] - #That's the end of the record - gmpte_info << journey unless record_ended - record_ended = true - end + z_journey.journey_route = JourneyRoute.new(parse_journey_route line) end - return {:journeys => journeys, :gmpte_info=>gmpte_info} + end + + return {:header => header, :locations => locations, :operators => operators, :journeys => journeys, :gmpte_info=>gmpte_info} + end + + def parse_header(string) + { + :file_type => string[0,8], + :version => "#{string[8,2].to_i}.#{string[10,2].to_i}", + :file_originator => string[12,32].strip!, + :source_product => string[44,16].strip!, + :production_datetime => string[60,14] + } + end + + def parse_bank_holiday(string) + { + :record_identity => string[0,2], + :transaction_type => string[2,1], + :date_of_bank_holiday => string[3,8] + } + end + + def parse_operator(string) + { + :record_identity => string[0,2], + :transaction_type => string[2,1], + :operator => parse_value(string[3,4]), + :operator_short_form => parse_value(string[7,24]), + :operator_legal_name => parse_value(string[31,48]) + } + end + + def parse_additonal_operator_info + { + :record_identity => string[0,2], + :address => string[77,3] + } + end + + def parse_additional_location_info(string) + { + :record_identity => string[0,2], + :transaction_type => string[2,1], + :location => string[3,12].strip, + :grid_reference_easting => parse_value(string[15,8]), + :grid_reference_northing => parse_value(string[23,8]) + } + end + + def parse_location(string) + { + :record_identity => string[0,2], + :transaction_type => string[2,1], + :location => parse_value(string[3,12]), + :full_location => parse_value(string[15,48]), + :gazetteer_code => string[63,1] + } end - # def parse_header(string) - # { - # Journey.new(:file_type => string[0,8], - # :version => "#{string[8,2].to_i}.#{string[10,2].to_i}", - # :file_originator => string[12,32].strip!, - # :source_product => string[44,16].strip!, - # :production_datetime => string[60,14]) - # } - # end - # - # def parse_bank_holiday(string) - # { - # BankHoliday.new(:record_identity => string[0,2], - # :transaction_type => string[2,1], - # :date_of_bank_holiday => string[3,8]) - # } - # end - # - # def parse_operator(string) - # { - # Operator.new(:record_identity => string[0,2], - # :transaction_type => string[2,1], - # :operator => parse_value(string[3,4]), - # :operator_short_form => parse_value(string[7,24]), - # :operator_legal_name => parse_value(string[31,48])) - # } - # end - # - # def parse_additional_location_info(string) - # { - # :record_identity => string[0,2], - # :transaction_type => string[2,1], - # :location => string[3,12].strip, - # :grid_reference_easting => parse_value(string[15,8]), - # :grid_reference_northing => parse_value(string[23,8]) - # } - # end - # - # def parse_location(string) - # { - # :record_identity => string[0,2], - # :transaction_type => string[2,1], - # :location => parse_value(string[3,12]), - # :full_location => parse_value(string[15,48]), - # :gazetteer_code => string[63,1] - # } - # end - # def parse_destination(string) { :record_identity => string[0,2], diff --git a/lib/atco/journey_times.rb b/lib/atco/journey_times.rb index c77ca7d..9586bf5 100644 --- a/lib/atco/journey_times.rb +++ b/lib/atco/journey_times.rb @@ -2,8 +2,8 @@ module Atco class JourneyTimes - attr_accessor :journey_identifiers, :record_identity, :start_time, :end_time, :days_of_the_week_text, :z_locations, :journey_route - attr_writer :journey_identifiers, :record_identity, :start_time, :end_time, :days_of_the_week_text, :z_locations, :journey_route + attr_accessor :journeys, :journey_identifiers, :record_identity, :start_time, :end_time, :days_of_the_week_text, :z_locations, :journey_route + attr_writer :journeys, :journey_identifiers, :record_identity, :start_time, :end_time, :days_of_the_week_text, :z_locations, :journey_route def initialize(data) @record_identity = data[:record_identity] diff --git a/lib/atco/location.rb b/lib/atco/location.rb index 78bc338..8c7508b 100644 --- a/lib/atco/location.rb +++ b/lib/atco/location.rb @@ -2,13 +2,12 @@ module Atco class Location - attr_accessor :name, :identifier, :easting, :northing, :gazeteer_code + attr_accessor :name, :identifier, :easting, :northing, :gazeteer_code, :short_code + attr_writer :name, :identifier, :easting, :northing, :gazeteer_code, :short_code - def initialize(location_header, additional_location_information) + def initialize(location_header) @name = location_header[:full_location] @identifier = location_header[:record_identity] - @easting = additional_location_information[:grid_reference_easting] - @northing = additional_location_information[:grid_reference_northing] @gazeteer_code = location_header[:gazetteer_code] end diff --git a/lib/atco/operator.rb b/lib/atco/operator.rb index b4de139..c32924d 100644 --- a/lib/atco/operator.rb +++ b/lib/atco/operator.rb @@ -2,8 +2,8 @@ module Atco class Operator - attr_accessor :record_identity, :transaction_type, :operator, :operator_short_form, :operator_legal_name - attr_writer :record_identity, :transaction_type, :operator, :operator_short_form, :operator_legal_name + attr_accessor :record_identity, :transaction_type, :operator, :operator_short_form, :operator_legal_name, :address + attr_writer :record_identity, :transaction_type, :operator, :operator_short_form, :operator_legal_name, :address def initialize(data) @record_identity = data[:record_identity]