Class: GeoRuby::GeoJSONFeatureCollection
- Inherits:
-
Object
- Object
- GeoRuby::GeoJSONFeatureCollection
- Defined in:
- lib/geo_ruby/geojson.rb
Overview
Class added to support geojson ‘Feature Collection’ objects
Instance Attribute Summary collapse
-
#features ⇒ Object
Returns the value of attribute features.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(features) ⇒ GeoJSONFeatureCollection
constructor
A new instance of GeoJSONFeatureCollection.
- #to_json(options = {}) ⇒ Object (also: #as_geojson)
Constructor Details
#initialize(features) ⇒ GeoJSONFeatureCollection
Returns a new instance of GeoJSONFeatureCollection.
50 51 52 |
# File 'lib/geo_ruby/geojson.rb', line 50 def initialize(features) @features = features end |
Instance Attribute Details
#features ⇒ Object
Returns the value of attribute features.
48 49 50 |
# File 'lib/geo_ruby/geojson.rb', line 48 def features @features end |
Instance Method Details
#==(other) ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/geo_ruby/geojson.rb', line 54 def ==(other) if (self.class != other.class) || (features.size != other.features.size) return false else features.each_index do |index| return false if features[index] != other.features[index] end end true end |
#to_json(options = {}) ⇒ Object Also known as: as_geojson
65 66 67 |
# File 'lib/geo_ruby/geojson.rb', line 65 def to_json( = {}) ({ type: 'FeatureCollection', features: features }).to_json end |