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.
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"] 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 |
Instance Method Details
#==(other) ⇒ Object
31 32 33 34 |
# File 'lib/bahn/bahn_station.rb', line 31 def == other return false if other.nil? other.name == self.name end |
#to_coordinates ⇒ Object Also known as: coordinates
26 27 28 |
# File 'lib/bahn/bahn_station.rb', line 26 def to_coordinates [lat, lon] end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/bahn/bahn_station.rb', line 22 def to_s "#{self.name} (#{self.lat},#{self.lon})" end |