Class: Aerospike::GeoJSON
- Inherits:
-
Object
- Object
- Aerospike::GeoJSON
- Defined in:
- lib/aerospike/geo_json.rb
Overview
Wrapper for GeoJSON data. GeoJSON data needs to be wrapped to allow the client to distinguish geospatial data from string (or hash) data. Geospatial data from a record’s bin will be returned as an instance of this class. The wrapper accepts GeoJSON data either as a String or a Hash.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(data) ⇒ GeoJSON
constructor
A new instance of GeoJSON.
- #to_hash ⇒ Object (also: #to_h)
- #to_json ⇒ Object (also: #to_s)
Constructor Details
#initialize(data) ⇒ GeoJSON
Returns a new instance of GeoJSON.
30 31 32 33 34 35 36 37 38 |
# File 'lib/aerospike/geo_json.rb', line 30 def initialize(data) self.json_data = case data when String data else data.to_json end end |
Instance Method Details
#==(other) ⇒ Object
50 51 52 53 |
# File 'lib/aerospike/geo_json.rb', line 50 def ==(other) return false unless other.class == self.class other.to_json == self.to_json end |
#to_hash ⇒ Object Also known as: to_h
45 46 47 |
# File 'lib/aerospike/geo_json.rb', line 45 def to_hash JSON.parse(json_data) end |
#to_json ⇒ Object Also known as: to_s
40 41 42 |
# File 'lib/aerospike/geo_json.rb', line 40 def to_json json_data end |