Class: Routing::GeoPoint
- Inherits:
-
Struct
- Object
- Struct
- Routing::GeoPoint
- Defined in:
- lib/routing/geo_point.rb
Overview
A GeoPoint object is a very simple representation of a geospatial point that is part of a route or can be used as base to create one.
It holds the most basic textual and geospatial information that is necessary to describe a section of a route.
The complete roundtrip from a Routing object through the Middleware to a Adapter and back uses arrays of GeoPoint objects as arguments.
Depending on your very own use-case, you can either extend the GeoPoint class or use another class that mimicks the behavior of GeoPoint. In fact, this is just a container class which is no hard requirement in general. If you decide to roll your own Adapter, Parser and maybe Middleware, you could replace the class completely
Instance Attribute Summary collapse
-
#distance ⇒ Object
Returns the value of attribute distance.
-
#lat ⇒ Object
Returns the value of attribute lat.
-
#lng ⇒ Object
Returns the value of attribute lng.
-
#original_lat ⇒ Object
Returns the value of attribute original_lat.
-
#original_lng ⇒ Object
Returns the value of attribute original_lng.
-
#relative_time ⇒ Object
Returns the value of attribute relative_time.
-
#type ⇒ Object
Returns the value of attribute type.
-
#waypoint ⇒ Object
Returns the value of attribute waypoint.
Instance Method Summary collapse
- #fetch(key, *args) ⇒ Object
-
#initialize(attributes = {}) ⇒ GeoPoint
constructor
Creates a new GeoPoint instance.
- #waypoint? ⇒ Boolean
Constructor Details
#initialize(attributes = {}) ⇒ GeoPoint
Creates a new GeoPoint instance.
23 24 25 26 27 |
# File 'lib/routing/geo_point.rb', line 23 def initialize(attributes = {}) attributes.each do |attribute, value| self[attribute] = value if members.include?(attribute) end end |
Instance Attribute Details
#distance ⇒ Object
Returns the value of attribute distance
17 18 19 |
# File 'lib/routing/geo_point.rb', line 17 def distance @distance end |
#lat ⇒ Object
Returns the value of attribute lat
17 18 19 |
# File 'lib/routing/geo_point.rb', line 17 def lat @lat end |
#lng ⇒ Object
Returns the value of attribute lng
17 18 19 |
# File 'lib/routing/geo_point.rb', line 17 def lng @lng end |
#original_lat ⇒ Object
Returns the value of attribute original_lat
17 18 19 |
# File 'lib/routing/geo_point.rb', line 17 def original_lat @original_lat end |
#original_lng ⇒ Object
Returns the value of attribute original_lng
17 18 19 |
# File 'lib/routing/geo_point.rb', line 17 def original_lng @original_lng end |
#relative_time ⇒ Object
Returns the value of attribute relative_time
17 18 19 |
# File 'lib/routing/geo_point.rb', line 17 def relative_time @relative_time end |
#type ⇒ Object
Returns the value of attribute type
17 18 19 |
# File 'lib/routing/geo_point.rb', line 17 def type @type end |
#waypoint ⇒ Object
Returns the value of attribute waypoint
17 18 19 |
# File 'lib/routing/geo_point.rb', line 17 def waypoint @waypoint end |
Instance Method Details
#fetch(key, *args) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/routing/geo_point.rb', line 33 def fetch(key, *args) raise ArgumentError, "wrong number of arguments (#{args.length + 1} for 1..2)" if args.length > 1 case key when *self.class.members send(key) else return yield(key) if block_given? return args.first unless args.empty? raise KeyError, "key #{key} not found" end end |
#waypoint? ⇒ Boolean
29 30 31 |
# File 'lib/routing/geo_point.rb', line 29 def waypoint? !!waypoint end |