Class: Ratis::Route

Inherits:
Object
  • Object
show all
Defined in:
lib/ratis/route.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(short_name, directions) ⇒ Route

Returns a new instance of Route.



21
22
23
24
# File 'lib/ratis/route.rb', line 21

def initialize(short_name, directions)
  self.short_name = short_name
  self.directions = directions
end

Instance Attribute Details

#directionsObject

Returns the value of attribute directions.



5
6
7
# File 'lib/ratis/route.rb', line 5

def directions
  @directions
end

#short_nameObject

Returns the value of attribute short_name.



5
6
7
# File 'lib/ratis/route.rb', line 5

def short_name
  @short_name
end

Class Method Details

.allObject



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/ratis/route.rb', line 7

def self.all
  response = Request.get 'Allroutes'
  return [] unless response.success?

  routes = response.to_hash[:allroutes_response][:routes].split(/\n/)
  atis_routes = routes.map do |r|
    r.strip!
    next if r.blank?
    r = r.split(/,/)
    Route.new r[0].strip, r[1..-1].map(&:strip)
  end
  atis_routes.compact
end

Instance Method Details

#timetable(conditions) ⇒ Object



26
27
28
# File 'lib/ratis/route.rb', line 26

def timetable(conditions)
  Timetable.where conditions.merge :route_short_name => short_name
end