Class: TTC::Stop

Inherits:
Object
  • Object
show all
Defined in:
lib/ttc-gps/models.rb

Overview

<stop lon=‘-79.5407149’ title=‘Lake Shore Blvd W At 39th’ tag=‘lake39th_e’ dirTag=‘501_eastbound’ stopId=‘6503’ lat=‘43.5928211’/>

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dirObject

Returns the value of attribute dir.



130
131
132
# File 'lib/ttc-gps/models.rb', line 130

def dir
  @dir
end

#idObject

Returns the value of attribute id.



130
131
132
# File 'lib/ttc-gps/models.rb', line 130

def id
  @id
end

#positionObject

Returns the value of attribute position.



130
131
132
# File 'lib/ttc-gps/models.rb', line 130

def position
  @position
end

#route_idObject

Returns the value of attribute route_id.



130
131
132
# File 'lib/ttc-gps/models.rb', line 130

def route_id
  @route_id
end

#tagObject

Returns the value of attribute tag.



130
131
132
# File 'lib/ttc-gps/models.rb', line 130

def tag
  @tag
end

#titleObject

Returns the value of attribute title.



130
131
132
# File 'lib/ttc-gps/models.rb', line 130

def title
  @title
end

Class Method Details

.parse_element(element) ⇒ Object

Parses an XML element into a Stop instance



144
145
146
147
148
149
150
151
152
153
154
# File 'lib/ttc-gps/models.rb', line 144

def Stop.parse_element element
  attrs = element.attributes
  
  s = Stop.new
  s.id = attrs["stopId"]
  s.title = attrs["title"]
  s.position = Geokit::LatLng.new(Float(attrs["lat"]), Float(attrs["lon"]))
  s.dir = attrs["dirTag"]
  s.tag = attrs["tag"]
  s
end

Instance Method Details

#to_json(*args) ⇒ Object



132
133
134
135
136
137
138
139
140
141
# File 'lib/ttc-gps/models.rb', line 132

def to_json *args
  {
    'id' => @id,
    'title' => @title,
    'position' => @position,
    'dir' => @dir,
    'tag' => @tag,
    'routeId' => @route_id
  }.to_json(*args)
end