ldbws 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +14 -0
  3. data/.envrc +1 -0
  4. data/.gitignore +8 -0
  5. data/Gemfile +3 -0
  6. data/Gemfile.lock +79 -0
  7. data/LICENSE +21 -0
  8. data/Makefile +8 -0
  9. data/README.md +47 -0
  10. data/doc/LICENSE.html +93 -0
  11. data/doc/Ldbws/Request/GetDeparturesBoard.html +114 -0
  12. data/doc/Ldbws/Request/GetDeparturesBoardWithDetails.html +116 -0
  13. data/doc/Ldbws/Request/GetServiceDetails.html +105 -0
  14. data/doc/Ldbws/Request/GetStationBoard.html +120 -0
  15. data/doc/Ldbws/Request/GetStationBoardWithDetails.html +120 -0
  16. data/doc/Ldbws/Request.html +91 -0
  17. data/doc/Ldbws/ResponseTypes/BaseStationBoard.html +108 -0
  18. data/doc/Ldbws/ResponseTypes/CallingPoint.html +129 -0
  19. data/doc/Ldbws/ResponseTypes/Coach.html +114 -0
  20. data/doc/Ldbws/ResponseTypes/DepartureItem.html +108 -0
  21. data/doc/Ldbws/ResponseTypes/DepartureItemWithDetails.html +108 -0
  22. data/doc/Ldbws/ResponseTypes/DeparturesBoard.html +105 -0
  23. data/doc/Ldbws/ResponseTypes/DeparturesBoardWithDetails.html +105 -0
  24. data/doc/Ldbws/ResponseTypes/Formation.html +108 -0
  25. data/doc/Ldbws/ResponseTypes/LoadingCategory.html +105 -0
  26. data/doc/Ldbws/ResponseTypes/Location.html +105 -0
  27. data/doc/Ldbws/ResponseTypes/ServiceDetails.html +143 -0
  28. data/doc/Ldbws/ResponseTypes/ServiceItem.html +132 -0
  29. data/doc/Ldbws/ResponseTypes/ServiceItemWithCallingPoints.html +106 -0
  30. data/doc/Ldbws/ResponseTypes/StationBoard.html +107 -0
  31. data/doc/Ldbws/ResponseTypes/StationBoardWithDetails.html +107 -0
  32. data/doc/Ldbws/ResponseTypes/ToiletAvailability.html +108 -0
  33. data/doc/Ldbws/ResponseTypes.html +91 -0
  34. data/doc/Ldbws/Service.html +538 -0
  35. data/doc/Ldbws.html +149 -0
  36. data/doc/README_md.html +159 -0
  37. data/doc/created.rid +19 -0
  38. data/doc/css/fonts.css +167 -0
  39. data/doc/css/rdoc.css +662 -0
  40. data/doc/fonts/Lato-Light.ttf +0 -0
  41. data/doc/fonts/Lato-LightItalic.ttf +0 -0
  42. data/doc/fonts/Lato-Regular.ttf +0 -0
  43. data/doc/fonts/Lato-RegularItalic.ttf +0 -0
  44. data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
  45. data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
  46. data/doc/images/add.png +0 -0
  47. data/doc/images/arrow_up.png +0 -0
  48. data/doc/images/brick.png +0 -0
  49. data/doc/images/brick_link.png +0 -0
  50. data/doc/images/bug.png +0 -0
  51. data/doc/images/bullet_black.png +0 -0
  52. data/doc/images/bullet_toggle_minus.png +0 -0
  53. data/doc/images/bullet_toggle_plus.png +0 -0
  54. data/doc/images/date.png +0 -0
  55. data/doc/images/delete.png +0 -0
  56. data/doc/images/find.png +0 -0
  57. data/doc/images/loadingAnimation.gif +0 -0
  58. data/doc/images/macFFBgHack.png +0 -0
  59. data/doc/images/package.png +0 -0
  60. data/doc/images/page_green.png +0 -0
  61. data/doc/images/page_white_text.png +0 -0
  62. data/doc/images/page_white_width.png +0 -0
  63. data/doc/images/plugin.png +0 -0
  64. data/doc/images/ruby.png +0 -0
  65. data/doc/images/tag_blue.png +0 -0
  66. data/doc/images/tag_green.png +0 -0
  67. data/doc/images/transparent.png +0 -0
  68. data/doc/images/wrench.png +0 -0
  69. data/doc/images/wrench_orange.png +0 -0
  70. data/doc/images/zoom.png +0 -0
  71. data/doc/index.html +165 -0
  72. data/doc/js/darkfish.js +84 -0
  73. data/doc/js/navigation.js +105 -0
  74. data/doc/js/navigation.js.gz +0 -0
  75. data/doc/js/search.js +110 -0
  76. data/doc/js/search_index.js +1 -0
  77. data/doc/js/search_index.js.gz +0 -0
  78. data/doc/js/searcher.js +229 -0
  79. data/doc/js/searcher.js.gz +0 -0
  80. data/doc/table_of_contents.html +299 -0
  81. data/ldbws.gemspec +25 -0
  82. data/lib/ldbws/request/base.rb +69 -0
  83. data/lib/ldbws/request/get_departures_board.rb +54 -0
  84. data/lib/ldbws/request/get_service_details.rb +29 -0
  85. data/lib/ldbws/request/get_station_board.rb +60 -0
  86. data/lib/ldbws/response_types/base.rb +34 -0
  87. data/lib/ldbws/response_types/calling_point.rb +40 -0
  88. data/lib/ldbws/response_types/departures_board.rb +39 -0
  89. data/lib/ldbws/response_types/formation.rb +49 -0
  90. data/lib/ldbws/response_types/parsing_functions.rb +177 -0
  91. data/lib/ldbws/response_types/service_details.rb +69 -0
  92. data/lib/ldbws/response_types/service_item.rb +77 -0
  93. data/lib/ldbws/response_types/station_board.rb +50 -0
  94. data/lib/ldbws/service.rb +218 -0
  95. data/lib/ldbws/utils.rb +60 -0
  96. data/lib/ldbws/version.rb +4 -0
  97. data/lib/ldbws.rb +13 -0
  98. data/spec/response_types/parsing_spec.rb +46 -0
  99. data/spec/spec_helper.rb +4 -0
  100. metadata +224 -0
@@ -0,0 +1,29 @@
1
+ require "ldbws/request/base"
2
+
3
+ require "ldbws/response_types/service_details"
4
+
5
+ module Ldbws::Request
6
+ # Returns details about a particular service. Corresponds to +GetServiceDetailsResponse+ in the LDBWS schema.
7
+ #
8
+ # === Parameters
9
+ # service_id:: the ID of the service (required)
10
+ class GetServiceDetails < Base
11
+ # :nodoc:
12
+ SCHEMA = Dry::Schema.Params do
13
+ required(:service_id).filled(:string)
14
+ end
15
+
16
+ # :nodoc:
17
+ RESULT_XPATH = "GetServiceDetailsResult"
18
+
19
+ # :nodoc:
20
+ RESULT_TYPE = Ldbws::ResponseTypes::ServiceDetails
21
+
22
+ # :nodoc:
23
+ def to_soap_params
24
+ {
25
+ serviceID: @params[:service_id],
26
+ }
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,60 @@
1
+ require "ldbws/request/base"
2
+
3
+ require "ldbws/response_types/station_board"
4
+
5
+ module Ldbws::Request
6
+ # Returns an arrival or departure board for a given station. Corresponds to +GetStationBoardRequest+ in the LDBWS
7
+ # schema.
8
+ #
9
+ # === Parameters
10
+ # crs:: the CRS code for the station (required)
11
+ # num_rows:: the number of services to include (optional)
12
+ # filter_crs:: a CRS code for a station to filter arrivals from/departures to (optional)
13
+ # filter_type:: either ‘to’ or ‘from’ (optional)
14
+ # time_offset:: the offset from the current time—in minutes—to return departure information (optional).
15
+ # time_window:: how far into the future—relative to +:time_offset+—to return service information for (optional).
16
+ class GetStationBoard < Base
17
+ # :nodoc:
18
+ SCHEMA = Dry::Schema.Params do
19
+ required(:crs).filled(Types::Crs)
20
+ optional(:num_rows).filled(:integer)
21
+ optional(:filter_crs).filled(Types::Crs)
22
+ optional(:filter_type).filled(Types::FilterType)
23
+ optional(:time_offset).filled(:integer)
24
+ optional(:time_window).filled(:integer)
25
+ end
26
+
27
+ # :nodoc:
28
+ RESULT_XPATH = "GetStationBoardResult"
29
+
30
+ # :nodoc:
31
+ RESULT_TYPE = Ldbws::ResponseTypes::StationBoard
32
+
33
+ # :nodoc:
34
+ def to_soap_params
35
+ @params.tap do |params|
36
+ # CRSes should always be upcased
37
+ params[:crs].upcase!
38
+ params[:filter_crs].upcase! if params[:filter_crs]
39
+
40
+ # filter type isn’t needed if we’re not filtering
41
+ params.delete(:filter_type) unless params[:filter_crs]
42
+ end
43
+ end
44
+ end
45
+
46
+ # Returns an arrival or departure board for a given station with full service details. Corresponds to
47
+ # +GetStationBoardWithDetailsRequest+ in the LDBWS schema.
48
+ #
49
+ # === Parameters
50
+ # crs:: the CRS code for the station (required)
51
+ # num_rows:: the number of services to include (optional)
52
+ # filter_crs:: a CRS code for a station to filter arrivals from/departures to (optional)
53
+ # filter_type:: either ‘to’ or ‘from’ (optional)
54
+ # time_offset:: the offset from the current time—in minutes—to return departure information (optional).
55
+ # time_window:: how far into the future—relative to +:time_offset+—to return service information for (optional).
56
+ class GetStationBoardWithDetails < GetStationBoard
57
+ # :nodoc:
58
+ RESULT_TYPE = Ldbws::ResponseTypes::StationBoardWithDetails
59
+ end
60
+ end
@@ -0,0 +1,34 @@
1
+ require "ldbws/utils"
2
+
3
+ require "ldbws/response_types/parsing_functions"
4
+
5
+ # This module defines specific response types that map 1:1 with corresponding types in the LDBWS service schema. Sadly
6
+ # these are not especially well-documented.
7
+ #
8
+ # A lot of the Ruby side here works using a DSL to programatically define how XML nodes should be converted into Ruby
9
+ # objects: this is defined in {ParsingFunctions}.
10
+ module Ldbws::ResponseTypes # :nodoc:
11
+ # \Base class which defines most of the functionality required by subclasses.
12
+ class Base # :nodoc:
13
+ include ParsingFunctions
14
+
15
+ def method_missing(prop)
16
+ @props.fetch(prop)
17
+ end
18
+
19
+ def to_h
20
+ @props.to_h do |k, v|
21
+ [
22
+ k,
23
+ Ldbws::Utils.deep_hashify_value(v),
24
+ ]
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def initialize(props)
31
+ @props = props
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,40 @@
1
+ require "ldbws/response_types/base"
2
+ require "ldbws/response_types/formation"
3
+
4
+ module Ldbws::ResponseTypes
5
+ # Represents a calling point in the LDBWS.
6
+ #
7
+ # === Properties
8
+ # location_name:: the name of the station
9
+ # crs:: the CRS of the station
10
+ # st:: the scheduled time (as a Time object)
11
+ # et:: the expected time (as a String)
12
+ # at:: the actual time (as a string)
13
+ # cancelled::
14
+ # length::
15
+ # detatch_front::
16
+ # formation:: information about the formation of the train
17
+ # adhoc_alerts::
18
+ # cancel_reason::
19
+ # delay_reason::
20
+ # affected_by_diversion::
21
+ # reroute_delay::
22
+ # affected_by::
23
+ class CallingPoint < Base
24
+ property :location_name, String
25
+ property :crs, String
26
+ property :st, Time
27
+ property :et, String
28
+ property :at, String
29
+ property :cancelled, Boolean, selector: "isCancelled"
30
+ property :length, Integer
31
+ property :detatch_front, Boolean, default: false
32
+ property :formation, Formation
33
+ collection :adhoc_alerts, "adhocAlertText", String
34
+ property :cancel_reason, String
35
+ property :delay_reason, String
36
+ property :affected_by_diversion, Boolean, default: false
37
+ property :reroute_delay, Integer, default: 0
38
+ property :affected_by, String
39
+ end
40
+ end
@@ -0,0 +1,39 @@
1
+ require "ldbws/response_types/base"
2
+ require "ldbws/response_types/station_board"
3
+
4
+ module Ldbws::ResponseTypes
5
+ # Represents an item on a departure board.
6
+ #
7
+ # === Properties
8
+ # crs:: the CRS for the item
9
+ # service:: a ServiceItem[rdoc-ref:ServiceItem] representing this service.
10
+ class DepartureItem < Base
11
+ property :crs, String, selector: "@crs"
12
+ property :service, ServiceItem
13
+ end
14
+
15
+ # Represents an item on a departure board with additional details.
16
+ #
17
+ # === Properties
18
+ # crs:: the CRS for the item
19
+ # service:: a ServiceItemWithCallingPoints[rdoc-ref:ServiceItemWithCallingPoints] representing this service.
20
+ class DepartureItemWithDetails < Base
21
+ property :crs, String, selector: "@crs"
22
+ property :service, ServiceItemWithCallingPoints
23
+ end
24
+
25
+ # Represents a departures board.
26
+ #
27
+ # === Properties
28
+ # departures:: a list of departures[rdoc-ref:DepartureItem].
29
+ class DeparturesBoard < BaseStationBoard
30
+ collection :departures, "destination", DepartureItem
31
+ end
32
+
33
+ # Represents a departures board with additional details.
34
+ # === Properties
35
+ # departures:: a list of departures[rdoc-ref:DepartureItemWithDetails].
36
+ class DeparturesBoardWithDetails < BaseStationBoard
37
+ collection :departures, "destination", DepartureItemWithDetails
38
+ end
39
+ end
@@ -0,0 +1,49 @@
1
+ require "ldbws/response_types/base"
2
+
3
+ module Ldbws::ResponseTypes
4
+ # The loading category of a train
5
+ #
6
+ # === Properties
7
+ # code::
8
+ # colour::
9
+ # image::
10
+ class LoadingCategory < Base
11
+ property :code, String
12
+ property :colour, String
13
+ property :image, String
14
+ end
15
+
16
+ # The availability of an individual toilet on a train
17
+ #
18
+ # === Properties
19
+ # type:: the type of toilet
20
+ # status:: whether the toilet is in- or out of service
21
+ class ToiletAvailability < Base
22
+ property :type, String, selector: "."
23
+ property :status, String, selector: "@status", default: "InService"
24
+ end
25
+
26
+ # Information about an individual coach in the train.
27
+ #
28
+ # === Properties
29
+ # number:: the coach number or identifier
30
+ # class:: the class of the coach—usually ‘standard’ or ‘first’
31
+ # toilet:: information about {toilets}[rdoc-ref:ToiletAvailability] in the carriage
32
+ # loading:: the loading of the carriage, as a percentage from 0–100.
33
+ class Coach < Base
34
+ property :number, String, selector: "@number"
35
+ property :class, String, selector: "coachClass"
36
+ property :toilet, ToiletAvailability
37
+ property :loading, Integer
38
+ end
39
+
40
+ # Information about the formation of a train
41
+ #
42
+ # === Properties
43
+ # loading_category:: how heavily-loaded the train is. Provided as as LoadingCategory
44
+ # coaches:: descriptions of each of the {carriages}[rdoc-ref:Coach] in the train
45
+ class Formation < Base
46
+ property :loading_category, LoadingCategory
47
+ collection :coaches, "coach", Coach
48
+ end
49
+ end
@@ -0,0 +1,177 @@
1
+ module Ldbws::ResponseTypes # :nodoc:
2
+ # Provides a DSL-type interface for easily defining the conversion from XML to PORO.
3
+ #
4
+ # It does this through the provision of two methods: {#property}, which defines a single property of a specified type,
5
+ # and {#collection} which defines a list of the same.
6
+ #
7
+ # Thus, given some XML like:
8
+ #
9
+ # <foo>text</foo>
10
+ # <bar>
11
+ # <value>one</value>
12
+ # <value>two</value>
13
+ # <value>three</value>
14
+ # </bar>
15
+ #
16
+ # Your DSL would look something like:
17
+ #
18
+ # property :foo, String
19
+ # collection :bar, "Value", String
20
+ #
21
+ # === Nested parsing
22
+ #
23
+ # Both [#property] and [#collection] take a class that is used to convert from the XML value to Ruby. This can be
24
+ # any normal Ruby class that response to either +#new+ or +#parse+ (like [Date]).
25
+ # Additionally, this can be another class implementing this module, in which case the #from_xml method is used.
26
+ module ParsingFunctions # :nodoc:
27
+ def self.included(base)
28
+ base.extend(ClassFunctions)
29
+ end
30
+
31
+ module ClassFunctions # :nodoc:
32
+ # Creates an object from an XML node.
33
+ #
34
+ # === Parameters
35
+ # xml_node:: the {XML node}[rdoc-ref:Nokogiri:XML::Node] to parse
36
+ def from_xml(xml_node)
37
+ raise "Oh no" if properties.empty?
38
+
39
+ props = properties.dup.map do |key, defn|
40
+ # look for the node, and return the default if we can’t find it
41
+ found = xml_node.xpath("./#{defn[:selector]}")
42
+ next [key, defn[:default]] unless found.any?
43
+
44
+ [
45
+ key,
46
+ if defn[:collection]
47
+ found.map { |node| parse_property(node, defn) }.compact
48
+ else
49
+ parse_property(found.first, defn)
50
+ end,
51
+ ]
52
+ end.to_h
53
+
54
+ new(props)
55
+ end
56
+
57
+ protected
58
+
59
+ # Defines a single property to be parsed from the XML.
60
+ #
61
+ # === Examples
62
+ #
63
+ # Given the structure
64
+ #
65
+ # <foo>text content</foo>
66
+ # <bar>3.1415</bar>
67
+ # <blah>Some more content</blah>
68
+ #
69
+ # and
70
+ #
71
+ # property :foo, String
72
+ # property :bar, Float
73
+ # property :baz, String, selctor: "blah" # selects the value from <blah>, but stores it as `:baz`
74
+ #
75
+ # === Parameters
76
+ # key:: the name of the property. This us used to select the node in XML unless `:selector` is specified.
77
+ # klass:: the Ruby class to use when parsing the value.
78
+ # selector:: an optional XPath selector. If not specified, a snake_case version of `:key` is used instead.
79
+ # default:: an optional default value for the property if the specified XML node cannot be found.
80
+ def property(key, klass, selector: nil, default: nil)
81
+ selector ||= Ldbws::Utils.to_snake_case(key.to_s)
82
+
83
+ @_properties ||= {}
84
+ @_properties[key] = {
85
+ key: key,
86
+ selector: selector,
87
+ klass: klass,
88
+ default: default,
89
+ collection: false,
90
+ }
91
+ end
92
+
93
+ # Defines an array of a single type to be parsed from the XML.
94
+ #
95
+ # === Examples
96
+ #
97
+ # Given the structure
98
+ #
99
+ # <foo>
100
+ # <value>…</value>
101
+ # <value>…</value>
102
+ # </foo>
103
+ #
104
+ # and
105
+ #
106
+ # property :foo, "value", String
107
+ # property :bar, "value", String, selector: "foo" # selects the same as above, just aliased as :bar
108
+ #
109
+ # === Parameters
110
+ # key:: the name of the property. This us used to select the node in XML unless +:selector+ is specified.
111
+ # option_selector:: a selector for the ‘child’ node that contains the additional value
112
+ # klass:: the Ruby class to use when parsing the value.
113
+ # selector:: an optional XPath selector to use when getting the ‘root’ node. If left unspecified, a +snake_case+
114
+ # version of +:key+ is used.
115
+ # default:: an optional default value, if the specified XML node cannot be found.
116
+ def collection(key, option_selector, klass, selector: nil, default: [])
117
+ selector ||= Ldbws::Utils.to_snake_case(key.to_s)
118
+
119
+ @_properties ||= {}
120
+ @_properties[key] = {
121
+ key: key,
122
+ selector: "#{selector}/#{option_selector}",
123
+ klass: klass,
124
+ default: default,
125
+ collection: true,
126
+ }
127
+ end
128
+
129
+ # Used by #inherited to copy properties from parents to children
130
+ def properties=(props) # :nodoc:
131
+ @_properties = props
132
+ end
133
+
134
+ private
135
+
136
+ # Returns the properties
137
+ def properties
138
+ @_properties
139
+ end
140
+
141
+ def inherited(sub)
142
+ sub.properties = @_properties.dup
143
+ end
144
+
145
+ def parse_property(xml_node, definition)
146
+ return definition[:default] if xml_node.children.empty?
147
+
148
+ klass = definition[:klass]
149
+ content = xml_node.content
150
+
151
+ if klass.respond_to?(:parse)
152
+ klass.parse(content)
153
+ elsif klass.respond_to?(:from_xml)
154
+ klass.from_xml(xml_node)
155
+ elsif klass.respond_to?(:new)
156
+ klass.new(content)
157
+ else
158
+ content
159
+ end
160
+ end
161
+ end
162
+ end
163
+
164
+ # Provides a Boolean type for use with the DSL.
165
+ class Boolean # :nodoc:
166
+ def self.parse(value)
167
+ value.downcase == "true"
168
+ end
169
+ end
170
+
171
+ # Provides a self-stripping string for use with the DSL.
172
+ class StrippedString # :nodoc:
173
+ def self.parse(value)
174
+ value.strip
175
+ end
176
+ end
177
+ end
@@ -0,0 +1,69 @@
1
+ require "ldbws/response_types/base"
2
+ require "ldbws/response_types/formation"
3
+
4
+ module Ldbws::ResponseTypes
5
+ # Represents details about a service in LDBWS.
6
+ #
7
+ # === Properties
8
+ # generatedAt::
9
+ # service_type::
10
+ # location_name::
11
+ # crs::
12
+ # operator::
13
+ # operator_code::
14
+ # rsid::
15
+ # cancelled::
16
+ # cancel_reason::
17
+ # delay_reason::
18
+ # overdue_message::
19
+ # length::
20
+ # detach_front::
21
+ # reverse_formation::
22
+ # platform::
23
+ # sta:: the scheduled arrival time as a Time object.
24
+ # eta:: the estimated arrival time, as a string
25
+ # ata:: the actual arrival time, as a string
26
+ # std:: the scheduled departure time as a Time object
27
+ # etd:: the estimated departure time, as a string
28
+ # atd:: the actual departure time, as a String
29
+ # diverted_via::
30
+ # diversion_reason::
31
+ # adhoc_alerts::
32
+ # formation:: information about the formation of the train
33
+ # previous_calling_points::
34
+ # subsequent_calling_points::
35
+ class ServiceDetails < Base
36
+ # from rtti_2017-10-01_ldb_types.xsd // BaseServiceDetails
37
+ property :generated_at, DateTime
38
+ property :service_type, String
39
+ property :location_name, String
40
+ property :crs, String
41
+ property :operator, String
42
+ property :operator_code, String
43
+ property :rsid, String
44
+ property :cancelled, Boolean, selector: "isCancelled", default: false
45
+ property :cancel_reason, String
46
+ property :delay_reason, String
47
+ property :overdue_message, String
48
+ property :length, Integer
49
+ property :detach_front, Boolean, default: false
50
+ property :reverse_formation, Boolean, selector: "isReverseFormation", default: false
51
+ property :platform, String
52
+ property :sta, Time
53
+ property :eta, String
54
+ property :ata, String
55
+ property :std, Time
56
+ property :etd, String
57
+ property :atd, String
58
+
59
+ # From rtti_2021-11-01_ldb_types.xsd // BaseServiceDetails
60
+ property :diverted_via, String
61
+ property :diversion_reason, String
62
+
63
+ # From rtti_2021-11-01_ldb_types.xsd // ServiceDetails
64
+ collection :adhoc_alerts, "adhocAlertText", String
65
+ property :formation, Formation
66
+ collection :previous_calling_points, "callingPointList/callingPoint", CallingPoint
67
+ collection :subsequent_calling_points, "callingPointList/callingPoint", CallingPoint
68
+ end
69
+ end
@@ -0,0 +1,77 @@
1
+ require "ldbws/response_types/base"
2
+ require "ldbws/response_types/calling_point"
3
+ require "ldbws/response_types/formation"
4
+
5
+ module Ldbws::ResponseTypes
6
+ # Represents a location in LDBWS.
7
+ #
8
+ # === Properties
9
+ # name::
10
+ # crs::
11
+ # via::
12
+ class Location < Base
13
+ property :name, String, selector: "locationName"
14
+ property :crs, String
15
+ property :via, String
16
+ end
17
+
18
+ # Represents a service item in LDBWS.
19
+ #
20
+ # === Properties
21
+ # sta:: the scheduled arrival time as a Time object
22
+ # eta:: the estimated arrival time as a string
23
+ # std:: the scheduled departure time as a Time object
24
+ # etd:: the estimated departure time as a string
25
+ # platform::
26
+ # operator::
27
+ # operator_code::
28
+ # circular_route::
29
+ # cancelled::
30
+ # service_type::
31
+ # length::
32
+ # detatch_front::
33
+ # reverse_formation::
34
+ # cancel_reason::
35
+ # delay_reason::
36
+ # service_id::
37
+ # adhoc_alerts::
38
+ # origin::
39
+ # destination::
40
+ # formation:: information about the formation of the train
41
+ class ServiceItem < Base
42
+ property :sta, Time
43
+ property :eta, String
44
+ property :std, Time
45
+ property :etd, String
46
+ property :platform, String
47
+ property :operator, String
48
+ property :operator_code, String
49
+ property :circular_route, Boolean, default: false, selector: "isCircularRoute"
50
+ property :cancelled, Boolean, default: false, selector: "isCancelled"
51
+ property :service_type, String
52
+ property :length, Integer
53
+ property :detach_front, Boolean, default: false
54
+ property :reverse_formation, Boolean, default: false, selector: "isReverseFormation"
55
+ property :cancel_reason, String
56
+ property :delay_reason, String
57
+ property :service_id, String, selector: "serviceID"
58
+ collection :adhoc_alerts, "adhocAlertText", String
59
+ collection :origin, "location", Location
60
+ collection :destination, "location", Location
61
+
62
+ # rtti_2021-11-01_ldb_types.xsd
63
+ property :formation, Formation
64
+ end
65
+
66
+ # Represents a service item with additional details in LDBWS: extends ServiceItem.
67
+ #
68
+ # === Properties
69
+ # As ServiceItem, and additionally:
70
+ #
71
+ # previous_calling_points::
72
+ # subsequent_calling_points::
73
+ class ServiceItemWithCallingPoints < ServiceItem
74
+ collection :previous_calling_points, "callingPointList/callingPoint", CallingPoint
75
+ collection :subsequent_calling_points, "callingPointList/callingPoint", CallingPoint
76
+ end
77
+ end
@@ -0,0 +1,50 @@
1
+ require "ldbws/response_types/base"
2
+ require "ldbws/response_types/service_item"
3
+
4
+ module Ldbws::ResponseTypes
5
+ # \Base station board information. This does not directly correspond to a type in LDBWS.
6
+ #
7
+ # === Properties
8
+ # generated_at::
9
+ # location_name::
10
+ # crs::
11
+ # nrcc_messages::
12
+ # platform_available::
13
+ # are_services_available::
14
+ class BaseStationBoard < Base
15
+ property :generated_at, DateTime
16
+ property :location_name, String
17
+ property :crs, String
18
+ collection :nrcc_messages, "message", StrippedString
19
+ property :platform_available, Boolean, default: false
20
+ property :are_services_available, Boolean, default: true
21
+ end
22
+
23
+ # Represents a station arrival/departure board in LDBWS.
24
+ #
25
+ # === Properties
26
+ # As BaseStationBoard, and additionally:
27
+ #
28
+ # train_services::
29
+ # bus_services::
30
+ # ferry_services::
31
+ class StationBoard < BaseStationBoard
32
+ collection :train_services, "service", ServiceItem
33
+ collection :bus_services, "service", ServiceItem
34
+ collection :ferry_services, "service", ServiceItem
35
+ end
36
+
37
+ # Represents a station arrival/departure board with additional details in LDBWS.
38
+ #
39
+ # === Properties
40
+ # As BaseStationBoard, and additionally:
41
+ #
42
+ # train_services::
43
+ # bus_services::
44
+ # ferry_services::
45
+ class StationBoardWithDetails < BaseStationBoard
46
+ collection :train_services, "service", ServiceItemWithCallingPoints
47
+ collection :bus_services, "service", ServiceItemWithCallingPoints
48
+ collection :ferry_services, "service", ServiceItemWithCallingPoints
49
+ end
50
+ end