Class: GeoAPI::Point
Instance Attribute Summary collapse
-
#coords ⇒ Object
Returns the value of attribute coords.
-
#geometry_type ⇒ Object
Returns the value of attribute geometry_type.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Point
constructor
A new instance of Point.
- #latitude ⇒ Object
- #longitude ⇒ Object
Methods inherited from Geometry
#coordinates, from_hash, from_json, new_from_class_name, #to_json, #type
Constructor Details
#initialize(*args) ⇒ Point
Returns a new instance of Point.
94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/geoapi/geometry.rb', line 94 def initialize *args params = args. params = params == {} ? nil : params puts "GEOAPI::Point.new #{params.to_json}" #raise ArgumentError, ":lat (latitude) must be sent as a parameter to the GeoAPI::Point constructor" unless params.has_key?(:lat) #raise ArgumentError, ":lng (longitude) must be sent as a parameter to the GeoAPI::Point constructor" unless params.has_key?(:lng) self.coords = [params[:lng].to_f, params[:lat].to_f] unless params.blank? || params[:lat].blank? super args end |
Instance Attribute Details
#coords ⇒ Object
Returns the value of attribute coords.
84 85 86 |
# File 'lib/geoapi/geometry.rb', line 84 def coords @coords end |
#geometry_type ⇒ Object
Returns the value of attribute geometry_type.
84 85 86 |
# File 'lib/geoapi/geometry.rb', line 84 def geometry_type @geometry_type end |
Instance Method Details
#latitude ⇒ Object
86 87 88 |
# File 'lib/geoapi/geometry.rb', line 86 def latitude coords[0] end |
#longitude ⇒ Object
90 91 92 |
# File 'lib/geoapi/geometry.rb', line 90 def longitude coords[1] end |