Class: Ratis::Pattern
- Inherits:
-
Object
- Object
- Ratis::Pattern
- Defined in:
- lib/ratis/pattern.rb
Defined Under Namespace
Classes: RouteInfo
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
-
#direction ⇒ Object
Returns the value of attribute direction.
-
#longest ⇒ Object
Returns the value of attribute longest.
-
#route_short_name ⇒ Object
Returns the value of attribute route_short_name.
-
#routeinfos ⇒ Object
Returns the value of attribute routeinfos.
-
#service_type ⇒ Object
Returns the value of attribute service_type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options) ⇒ Pattern
constructor
A new instance of Pattern.
Constructor Details
#initialize(options) ⇒ Pattern
Returns a new instance of Pattern.
5 6 7 |
# File 'lib/ratis/pattern.rb', line 5 def initialize() self.routeinfos = [:routeinfos] end |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
3 4 5 |
# File 'lib/ratis/pattern.rb', line 3 def date @date end |
#direction ⇒ Object
Returns the value of attribute direction.
3 4 5 |
# File 'lib/ratis/pattern.rb', line 3 def direction @direction end |
#longest ⇒ Object
Returns the value of attribute longest.
3 4 5 |
# File 'lib/ratis/pattern.rb', line 3 def longest @longest end |
#route_short_name ⇒ Object
Returns the value of attribute route_short_name.
3 4 5 |
# File 'lib/ratis/pattern.rb', line 3 def route_short_name @route_short_name end |
#routeinfos ⇒ Object
Returns the value of attribute routeinfos.
3 4 5 |
# File 'lib/ratis/pattern.rb', line 3 def routeinfos @routeinfos end |
#service_type ⇒ Object
Returns the value of attribute service_type.
3 4 5 |
# File 'lib/ratis/pattern.rb', line 3 def service_type @service_type end |
Class Method Details
.all(conditions) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/ratis/pattern.rb', line 9 def self.all(conditions) short_name = conditions.delete :route_short_name direction = conditions.delete :direction date = conditions.delete :date service_type = conditions.delete :service_type longest = conditions.delete :longest raise ArgumentError.new('You must provide a route_short_name') unless short_name raise ArgumentError.new('You must provide a direction') unless direction raise ArgumentError.new('You must provide a date') unless date raise ArgumentError.new('You must provide a service_type') unless service_type raise ArgumentError.new('You must provide a longest') unless longest Ratis.all_conditions_used? conditions response = Request.get 'Getpatterns', {'Route' => short_name, 'Direction' => direction, 'Date' => date, 'Servicetype' => service_type, 'Longest' => longest } return nil unless response.success? routeinfos = response.to_hash[:getpatterns_response][:routes][:routeinfo].map do |r| info = Pattern::RouteInfo.new info.route = r[:route] info.headsign = r[:signage] info.operate = r[:operator] info.effective = r[:effective] info.routeid = r[:routeid] info.routetype = r[:routetype] info.tripcount = r[:tripcount] info.school = r[:school] info end Pattern.new(:routeinfos => routeinfos) end |