Class: KVVLiveAPI::Stop

Inherits:
Object
  • Object
show all
Defined in:
lib/kvvliveapi/stop.rb

Overview

Instances of this class represent a stop operated by the KVV

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, stop_id, lat, lon) ⇒ Stop

Returns a new instance of Stop.



23
24
25
26
27
28
# File 'lib/kvvliveapi/stop.rb', line 23

def initialize(name, stop_id, lat, lon)
  @name = name
  @stop_id = stop_id
  @lat = lat
  @lon = lon
end

Instance Attribute Details

#latObject (readonly)

latitute of the location of the stop



18
19
20
# File 'lib/kvvliveapi/stop.rb', line 18

def lat
  @lat
end

#lonObject (readonly)

longitude of the location of the stop



21
22
23
# File 'lib/kvvliveapi/stop.rb', line 21

def lon
  @lon
end

#nameObject (readonly)

Name of the stop



12
13
14
# File 'lib/kvvliveapi/stop.rb', line 12

def name
  @name
end

#stop_idObject (readonly)

ID used to reference the stop



15
16
17
# File 'lib/kvvliveapi/stop.rb', line 15

def stop_id
  @stop_id
end

Class Method Details

.from_json(json) ⇒ Object



6
7
8
# File 'lib/kvvliveapi/stop.rb', line 6

def from_json(json)
  new(json['name'], json['id'], json['lat'], json['lon'])
end

Instance Method Details

#to_sObject



30
31
32
# File 'lib/kvvliveapi/stop.rb', line 30

def to_s
  @name + '(' + @stop_id.to_s + ')'
end