Class: DVB::Stop

Inherits:
Object
  • Object
show all
Defined in:
lib/dvb/find.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, lat, lng, name, priority, region, search_str, tarif_zones) ⇒ Stop

Returns a new instance of Stop.



30
31
32
33
34
35
36
37
38
39
# File 'lib/dvb/find.rb', line 30

def initialize(id, lat, lng, name, priority, region, search_str, tarif_zones)
  @id = id
  @lat = lat
  @lng = lng
  @name = name
  @priority = priority
  @region = region
  @search_str = search_str
  @tarif_zones = tarif_zones
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



28
29
30
# File 'lib/dvb/find.rb', line 28

def id
  @id
end

#latObject (readonly)

Returns the value of attribute lat.



28
29
30
# File 'lib/dvb/find.rb', line 28

def lat
  @lat
end

#lngObject (readonly)

Returns the value of attribute lng.



28
29
30
# File 'lib/dvb/find.rb', line 28

def lng
  @lng
end

#nameObject (readonly)

Returns the value of attribute name.



28
29
30
# File 'lib/dvb/find.rb', line 28

def name
  @name
end

#priorityObject (readonly)

Returns the value of attribute priority.



28
29
30
# File 'lib/dvb/find.rb', line 28

def priority
  @priority
end

#regionObject (readonly)

Returns the value of attribute region.



28
29
30
# File 'lib/dvb/find.rb', line 28

def region
  @region
end

#search_strObject (readonly)

Returns the value of attribute search_str.



28
29
30
# File 'lib/dvb/find.rb', line 28

def search_str
  @search_str
end

#tarif_zonesObject (readonly)

Returns the value of attribute tarif_zones.



28
29
30
# File 'lib/dvb/find.rb', line 28

def tarif_zones
  @tarif_zones
end

Class Method Details

.with_str_hash(h) ⇒ Object



41
42
43
44
45
# File 'lib/dvb/find.rb', line 41

def self.with_str_hash(h)
  lat = h['latitude'] == '999.999999' ? nil : h['latitude'].to_f
  lng = h['longitude'] == '999.999999' ? nil : h['longitude'].to_f
  Stop.new(h['id'], lat, lng, h['name'], h['priority'].to_i, h['region'], h['searchstring'], h['tarif_zones'])
end

Instance Method Details

#coordsObject



47
48
49
50
51
52
# File 'lib/dvb/find.rb', line 47

def coords
  {
    latitude: @lat,
    longitute: @lng
  }
end

#to_sObject



54
55
56
# File 'lib/dvb/find.rb', line 54

def to_s
  "#{@name}, #{@region}"
end