Class: Bort::Station::Station

Inherits:
Object
  • Object
show all
Defined in:
lib/bort/station.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#abbreviationObject

Returns the value of attribute abbreviation.



4
5
6
# File 'lib/bort/station.rb', line 4

def abbreviation
  @abbreviation
end

#addressObject

Returns the value of attribute address.



4
5
6
# File 'lib/bort/station.rb', line 4

def address
  @address
end

#attractionObject

Returns the value of attribute attraction.



4
5
6
# File 'lib/bort/station.rb', line 4

def attraction
  @attraction
end

#bike_flagObject

Returns the value of attribute bike_flag.



4
5
6
# File 'lib/bort/station.rb', line 4

def bike_flag
  @bike_flag
end

#bike_station_flagObject

Returns the value of attribute bike_station_flag.



4
5
6
# File 'lib/bort/station.rb', line 4

def bike_station_flag
  @bike_station_flag
end

#bike_station_textObject

Returns the value of attribute bike_station_text.



4
5
6
# File 'lib/bort/station.rb', line 4

def bike_station_text
  @bike_station_text
end

#car_shareObject

Returns the value of attribute car_share.



4
5
6
# File 'lib/bort/station.rb', line 4

def car_share
  @car_share
end

#cityObject

Returns the value of attribute city.



4
5
6
# File 'lib/bort/station.rb', line 4

def city
  @city
end

#countyObject

Returns the value of attribute county.



4
5
6
# File 'lib/bort/station.rb', line 4

def county
  @county
end

#cross_streetObject

Returns the value of attribute cross_street.



4
5
6
# File 'lib/bort/station.rb', line 4

def cross_street
  @cross_street
end

#destinationsObject

Returns the value of attribute destinations.



4
5
6
# File 'lib/bort/station.rb', line 4

def destinations
  @destinations
end

#enteringObject

Returns the value of attribute entering.



4
5
6
# File 'lib/bort/station.rb', line 4

def entering
  @entering
end

#exitingObject

Returns the value of attribute exiting.



4
5
6
# File 'lib/bort/station.rb', line 4

def exiting
  @exiting
end

#fill_timeObject

Returns the value of attribute fill_time.



4
5
6
# File 'lib/bort/station.rb', line 4

def fill_time
  @fill_time
end

#foodObject

Returns the value of attribute food.



4
5
6
# File 'lib/bort/station.rb', line 4

def food
  @food
end

#geoObject

Returns the value of attribute geo.



4
5
6
# File 'lib/bort/station.rb', line 4

def geo
  @geo
end

#introObject

Returns the value of attribute intro.



4
5
6
# File 'lib/bort/station.rb', line 4

def intro
  @intro
end

Returns the value of attribute link.



4
5
6
# File 'lib/bort/station.rb', line 4

def link
  @link
end

#locker_flagObject

Returns the value of attribute locker_flag.



4
5
6
# File 'lib/bort/station.rb', line 4

def locker_flag
  @locker_flag
end

#lockersObject

Returns the value of attribute lockers.



4
5
6
# File 'lib/bort/station.rb', line 4

def lockers
  @lockers
end

#north_platformsObject

Returns the value of attribute north_platforms.



4
5
6
# File 'lib/bort/station.rb', line 4

def north_platforms
  @north_platforms
end

#north_routesObject

Returns the value of attribute north_routes.



4
5
6
# File 'lib/bort/station.rb', line 4

def north_routes
  @north_routes
end

#parkingObject

Returns the value of attribute parking.



4
5
6
# File 'lib/bort/station.rb', line 4

def parking
  @parking
end

#parking_flagObject

Returns the value of attribute parking_flag.



4
5
6
# File 'lib/bort/station.rb', line 4

def parking_flag
  @parking_flag
end

#platform_infoObject

Returns the value of attribute platform_info.



4
5
6
# File 'lib/bort/station.rb', line 4

def platform_info
  @platform_info
end

#shoppingObject

Returns the value of attribute shopping.



4
5
6
# File 'lib/bort/station.rb', line 4

def shopping
  @shopping
end

#south_platformsObject

Returns the value of attribute south_platforms.



4
5
6
# File 'lib/bort/station.rb', line 4

def south_platforms
  @south_platforms
end

#south_routesObject

Returns the value of attribute south_routes.



4
5
6
# File 'lib/bort/station.rb', line 4

def south_routes
  @south_routes
end

#stateObject

Returns the value of attribute state.



4
5
6
# File 'lib/bort/station.rb', line 4

def state
  @state
end

#transit_infoObject

Returns the value of attribute transit_info.



4
5
6
# File 'lib/bort/station.rb', line 4

def transit_info
  @transit_info
end

#zipObject

Returns the value of attribute zip.



4
5
6
# File 'lib/bort/station.rb', line 4

def zip
  @zip
end

Class Method Details

.parse(doc) ⇒ Object



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
48
49
50
51
52
# File 'lib/bort/station.rb', line 11

def self.parse(doc)
  station = Station.new
  station.abbreviation      = (doc/:abbr).inner_text
  station.destinations      = (doc/:destinations).inner_text

  station.north_routes      = (doc/:north_routes/:route).map(&:inner_text)
  station.south_routes      = (doc/:south_routes/:route).map(&:inner_text)
  station.north_platforms   = (doc/:north_platforms/:platform).map(&:inner_text).map(&:to_i)
  station.south_platforms   = (doc/:south_platforms/:platform).map(&:inner_text).map(&:to_i)
  station.platform_info     = (doc/:platform_info).inner_text

  latitude                  = (doc/:gtfs_latitude).inner_text
  longitude                 = (doc/:gtfs_longitude).inner_text
  station.geo               = [latitude, longitude] if latitude and longitude
  station.address           = (doc/:address).inner_text
  station.city              = (doc/:city).inner_text
  station.county            = (doc/:county).inner_text
  station.state             = (doc/:state).inner_text
  station.zip               = (doc/:zipcode).inner_text
  station.cross_street      = (doc/:cross_street).inner_text

  station.bike_flag         = parse_flag(doc.attributes['bike_flag'])
  station.bike_station_flag = parse_flag(doc.attributes['bike_station_flag'])
  station.bike_station_text = (doc/:bike_station_text).inner_text
  station.parking           = (doc/:parking).inner_text
  station.parking_flag      = parse_flag(doc.attributes['parking_flag'])
  station.transit_info      = (doc/:transit_info).inner_text
  station.car_share         = (doc/:car_share).inner_text
  station.entering          = (doc/:entering).inner_text
  station.exiting           = (doc/:exiting).inner_text

  station.attraction        = (doc/:attraction).inner_text
  station.shopping          = (doc/:shopping).inner_text
  station.food              = (doc/:food).inner_text
  station.intro             = (doc/:intro).inner_text
  station.locker_flag       = parse_flag(doc.attributes['locker_flag'])
  station.lockers           = (doc/:lockers).inner_text
  station.fill_time         = (doc/:fill_time).inner_text
  station.link              = (doc/:link).inner_text

  station
end

.parse_flag(flag) ⇒ Object



54
55
56
57
58
59
60
# File 'lib/bort/station.rb', line 54

def self.parse_flag(flag)
  case flag
  when '1' then true
  when '0' then false
  else nil
  end
end