Class: TTC::Vehicle
- Inherits:
-
Object
- Object
- TTC::Vehicle
- Defined in:
- lib/ttc-gps/models.rb
Overview
<vehicle lon=‘-79.3582’ secsSinceReport=‘7’ predictable=‘true’ speedKmHr=‘0.0’ dirTag=‘504_westbound’ id=‘4142’ heading=‘54’ lat=‘43.677082’ routeTag=‘504’/>
Instance Attribute Summary collapse
-
#dir ⇒ Object
Returns the value of attribute dir.
-
#heading ⇒ Object
Returns the value of attribute heading.
-
#id ⇒ Object
Returns the value of attribute id.
-
#position ⇒ Object
Returns the value of attribute position.
-
#predictable ⇒ Object
Returns the value of attribute predictable.
-
#route ⇒ Object
Returns the value of attribute route.
-
#routeId ⇒ Object
Returns the value of attribute routeId.
-
#secs_since_report ⇒ Object
Returns the value of attribute secs_since_report.
-
#ts ⇒ Object
Returns the value of attribute ts.
Class Method Summary collapse
-
.parse_element(element) ⇒ Object
Parses an XML element into a Vehicle instance.
Instance Method Summary collapse
Instance Attribute Details
#dir ⇒ Object
Returns the value of attribute dir.
37 38 39 |
# File 'lib/ttc-gps/models.rb', line 37 def dir @dir end |
#heading ⇒ Object
Returns the value of attribute heading.
37 38 39 |
# File 'lib/ttc-gps/models.rb', line 37 def heading @heading end |
#id ⇒ Object
Returns the value of attribute id.
37 38 39 |
# File 'lib/ttc-gps/models.rb', line 37 def id @id end |
#position ⇒ Object
Returns the value of attribute position.
37 38 39 |
# File 'lib/ttc-gps/models.rb', line 37 def position @position end |
#predictable ⇒ Object
Returns the value of attribute predictable.
37 38 39 |
# File 'lib/ttc-gps/models.rb', line 37 def predictable @predictable end |
#route ⇒ Object
Returns the value of attribute route.
37 38 39 |
# File 'lib/ttc-gps/models.rb', line 37 def route @route end |
#routeId ⇒ Object
Returns the value of attribute routeId.
37 38 39 |
# File 'lib/ttc-gps/models.rb', line 37 def routeId @routeId end |
#secs_since_report ⇒ Object
Returns the value of attribute secs_since_report.
37 38 39 |
# File 'lib/ttc-gps/models.rb', line 37 def secs_since_report @secs_since_report end |
#ts ⇒ Object
Returns the value of attribute ts.
37 38 39 |
# File 'lib/ttc-gps/models.rb', line 37 def ts @ts end |
Class Method Details
.parse_element(element) ⇒ Object
Parses an XML element into a Vehicle instance
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/ttc-gps/models.rb', line 51 def Vehicle.parse_element element attrs = element.attributes v = Vehicle.new v.id = attrs["id"] v.route = attrs["routeTag"] v.position = Geokit::LatLng.new(Float(attrs["lat"]), Float(attrs["lon"])) v.heading = Float(attrs["heading"]) v.dir = attrs["dirTag"] v.secs_since_report = Integer(attrs["secsSinceReport"]) v.predictable = Boolean(attrs["predictable"]) v end |
Instance Method Details
#to_json(*args) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ttc-gps/models.rb', line 39 def to_json *args { 'id' => @id, 'routeId' => @routeId, 'position' => @position, 'heading' => @heading, 'dir' => @dir, 'ts' => @ts }.to_json(*args) end |