Class: GeoRuby::GeojsonFeatureCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/geo_ruby/geojson.rb

Overview

Class added to support geojson ‘Feature Collection’ objects

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(features) ⇒ GeojsonFeatureCollection

Returns a new instance of GeojsonFeatureCollection.



41
42
43
# File 'lib/geo_ruby/geojson.rb', line 41

def initialize(features)
  @features = features
end

Instance Attribute Details

#featuresObject

Returns the value of attribute features.



39
40
41
# File 'lib/geo_ruby/geojson.rb', line 39

def features
  @features
end

Instance Method Details

#==(other) ⇒ Object



45
46
47
48
49
50
51
52
53
54
# File 'lib/geo_ruby/geojson.rb', line 45

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



56
57
58
59
# File 'lib/geo_ruby/geojson.rb', line 56

def to_json(options = {})
  {:type => 'FeatureCollection',
    :features => features}.to_json(options)
end