Class: GeojsonImport
- Inherits:
-
Object
- Object
- GeojsonImport
- Defined in:
- lib/charta/geojson_import.rb
Instance Method Summary collapse
- #as_geojson ⇒ Object
-
#initialize(data) ⇒ GeojsonImport
constructor
TODO: handle a File object instead of calling IO read/write directly.
- #shapes(options = {}) ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(data) ⇒ GeojsonImport
TODO: handle a File object instead of calling IO read/write directly
5 6 7 8 |
# File 'lib/charta/geojson_import.rb', line 5 def initialize(data) @shapes = nil @xml = data end |
Instance Method Details
#as_geojson ⇒ Object
27 28 29 |
# File 'lib/charta/geojson_import.rb', line 27 def as_geojson @shapes.to_json end |
#shapes(options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/charta/geojson_import.rb', line 15 def shapes( = {}) [:to] ||= :json @shapes = JSON.parse(@xml) if [:to].equal? :json @shapes = @shapes.to_json elsif [:to].equal? :string @shapes = @shapes.to_s end end |