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.
53 54 55 |
# File 'lib/geo_ruby/geojson.rb', line 53 def initialize(features) @features = features end |
Instance Attribute Details
#features ⇒ Object
Returns the value of attribute features.
51 52 53 |
# File 'lib/geo_ruby/geojson.rb', line 51 def features @features end |
Instance Method Details
#==(other) ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/geo_ruby/geojson.rb', line 57 def ==(other) if (self.class != other.class) || (features.size != other.features.size) return false else features.each_index do |index| return false if self.features[index] != other.features[index] end end true end |
#to_json(options = {}) ⇒ Object Also known as: as_geojson
68 69 70 71 |
# File 'lib/geo_ruby/geojson.rb', line 68 def to_json( = {}) {:type => 'FeatureCollection', :features => features}.to_json() end |