Class: Bahn::Station
- Inherits:
-
Object
- Object
- Bahn::Station
- Defined in:
- lib/bahn/bahn_station.rb
Instance Attribute Summary collapse
-
#distance ⇒ Object
Returns the value of attribute distance.
-
#lat ⇒ Object
Returns the value of attribute lat.
-
#lon ⇒ Object
Returns the value of attribute lon.
-
#name ⇒ Object
Returns the value of attribute name.
-
#station_type ⇒ Object
Returns the value of attribute station_type.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(json = {}) ⇒ Station
constructor
A new instance of Station.
- #to_coordinates ⇒ Object (also: #coordinates)
- #to_s ⇒ Object
Constructor Details
#initialize(json = {}) ⇒ Station
Returns a new instance of Station.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/bahn/bahn_station.rb', line 5 def initialize json={} self.name = json["value"].to_s.gsub("(S-Bahn)", "(S)") unless json["value"].nil? if json[:do_load] station = Agent.new.find_station(name) if json[:load] == :station station = Agent.new.find_address(name) if json[:load] == :foot end if station.nil? self.lat = json["ycoord"].insert(-7, ".") unless json["ycoord"].nil? self.lon = json["xcoord"].insert(-7, ".") unless json["xcoord"].nil? else self.lat = station.lat self.lon = station.lon end end |
Instance Attribute Details
#distance ⇒ Object
Returns the value of attribute distance.
3 4 5 |
# File 'lib/bahn/bahn_station.rb', line 3 def distance @distance end |
#lat ⇒ Object
Returns the value of attribute lat.
3 4 5 |
# File 'lib/bahn/bahn_station.rb', line 3 def lat @lat end |
#lon ⇒ Object
Returns the value of attribute lon.
3 4 5 |
# File 'lib/bahn/bahn_station.rb', line 3 def lon @lon end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/bahn/bahn_station.rb', line 3 def name @name end |
#station_type ⇒ Object
Returns the value of attribute station_type.
3 4 5 |
# File 'lib/bahn/bahn_station.rb', line 3 def station_type @station_type end |
Instance Method Details
#==(other) ⇒ Object
32 33 34 35 |
# File 'lib/bahn/bahn_station.rb', line 32 def == other return false if other.nil? remove_parenthesis(other.name) == remove_parenthesis(name) end |
#to_coordinates ⇒ Object Also known as: coordinates
27 28 29 |
# File 'lib/bahn/bahn_station.rb', line 27 def to_coordinates [lat, lon] end |
#to_s ⇒ Object
22 23 24 25 |
# File 'lib/bahn/bahn_station.rb', line 22 def to_s return "#{self.name}" if (self.lat.nil? || self.lon.nil?) return "#{self.name} (#{self.lat},#{self.lon})" end |