Class: SFBATransitAPI::Route

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#agencyObject

Returns the value of attribute agency.



3
4
5
# File 'lib/sfba_transit_api/route.rb', line 3

def agency
  @agency
end

#codeObject

Returns the value of attribute code.



3
4
5
# File 'lib/sfba_transit_api/route.rb', line 3

def code
  @code
end

#directionsObject

Returns the value of attribute directions.



3
4
5
# File 'lib/sfba_transit_api/route.rb', line 3

def directions
  @directions
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/sfba_transit_api/route.rb', line 3

def name
  @name
end

#stopsObject

Returns the value of attribute stops.



3
4
5
# File 'lib/sfba_transit_api/route.rb', line 3

def stops
  @stops
end

Class Method Details

.parse(agency_node, agency) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/sfba_transit_api/route.rb', line 13

def self.parse(agency_node, agency)
  agency_node.xpath(".//Route").map do |route_node|
    route = new


    route.agency = agency
    route.name = route_node["Name"]
    route.code = route_node["Code"]

    route.directions = Direction.parse(route_node, route)
    route.stops = Stop.parse(route_node, route)

    route
  end
end

Instance Method Details

#has_directionObject



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

def has_direction
  directions.count > 0
end

#to_sObject



9
10
11
# File 'lib/sfba_transit_api/route.rb', line 9

def to_s
  "#<SFBATransitAPI::Route:#{object_id} @name=\"#{name}\", @code=\"#{code}\", @direction_codes=\"#{direction_codes}\", @agency=<SFBATransitAPI::Agency:#{agency.object_id}>, directions.count=#{directions.count}, stops.count=#{stops.count}>"
end