Class: Bahn::Station

Inherits:
Object
  • Object
show all
Defined in:
lib/bahn/bahn_station.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#distanceObject

Returns the value of attribute distance.



3
4
5
# File 'lib/bahn/bahn_station.rb', line 3

def distance
  @distance
end

#latObject

Returns the value of attribute lat.



3
4
5
# File 'lib/bahn/bahn_station.rb', line 3

def lat
  @lat
end

#lonObject

Returns the value of attribute lon.



3
4
5
# File 'lib/bahn/bahn_station.rb', line 3

def lon
  @lon
end

#nameObject

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_coordinatesObject Also known as: coordinates



26
27
28
# File 'lib/bahn/bahn_station.rb', line 26

def to_coordinates
	[lat, lon]
end

#to_sObject



22
23
24
# File 'lib/bahn/bahn_station.rb', line 22

def to_s
	"#{self.name} (#{self.lat},#{self.lon})"
end