Class: Geoiq::Map
Instance Attribute Summary collapse
-
#basemap ⇒ Object
Returns the value of attribute basemap.
-
#description ⇒ Object
Returns the value of attribute description.
-
#extent ⇒ Object
Returns the value of attribute extent.
-
#geoiq_id ⇒ Object
Returns the value of attribute geoiq_id.
-
#json ⇒ Object
Returns the value of attribute json.
-
#layers ⇒ Object
Returns the value of attribute layers.
-
#published ⇒ Object
Returns the value of attribute published.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#title ⇒ Object
Returns the value of attribute title.
Attributes inherited from BaseModel
Instance Method Summary collapse
-
#add_layer(layer) ⇒ Object
layers are an array of ids of datasets to add.
- #attributes ⇒ Object
- #create(options = {}) ⇒ Object
- #delete ⇒ Object
- #find(id, options = {}) ⇒ Object
-
#initialize(auth, options = {}) ⇒ Map
constructor
A new instance of Map.
- #update(options = {}) ⇒ Object
Methods inherited from BaseModel
Constructor Details
#initialize(auth, options = {}) ⇒ Map
Returns a new instance of Map.
11 12 13 14 15 16 17 18 19 |
# File 'lib/geoiq/map.rb', line 11 def initialize(auth, ={}) self.geoiq_id = .delete(:geoiq_id) if .include?(:geoiq_id) self.title = [:title] || "Untitled Map" self. = ([:tags] || []).join(",") self.extent = [:extent] || [-180,-90,180,90] self.basemap = [:basemap] || "Acetate" self.layers = [:layers] || [] super end |
Instance Attribute Details
#basemap ⇒ Object
Returns the value of attribute basemap.
5 6 7 |
# File 'lib/geoiq/map.rb', line 5 def basemap @basemap end |
#description ⇒ Object
Returns the value of attribute description.
5 6 7 |
# File 'lib/geoiq/map.rb', line 5 def description @description end |
#extent ⇒ Object
Returns the value of attribute extent.
5 6 7 |
# File 'lib/geoiq/map.rb', line 5 def extent @extent end |
#geoiq_id ⇒ Object
Returns the value of attribute geoiq_id.
5 6 7 |
# File 'lib/geoiq/map.rb', line 5 def geoiq_id @geoiq_id end |
#json ⇒ Object
Returns the value of attribute json.
5 6 7 |
# File 'lib/geoiq/map.rb', line 5 def json @json end |
#layers ⇒ Object
Returns the value of attribute layers.
5 6 7 |
# File 'lib/geoiq/map.rb', line 5 def layers @layers end |
#published ⇒ Object
Returns the value of attribute published.
5 6 7 |
# File 'lib/geoiq/map.rb', line 5 def published @published end |
#tags ⇒ Object
Returns the value of attribute tags.
5 6 7 |
# File 'lib/geoiq/map.rb', line 5 def @tags end |
#title ⇒ Object
Returns the value of attribute title.
5 6 7 |
# File 'lib/geoiq/map.rb', line 5 def title @title end |
Instance Method Details
#add_layer(layer) ⇒ Object
layers are an array of ids of datasets to add
52 53 54 55 56 57 58 |
# File 'lib/geoiq/map.rb', line 52 def add_layer(layer) requires_geoiq_id = {:source => "finder:#{layer}"} response = request(:post, "/maps/#{self.geoiq_id}/layers.json", {:query => }) layer_index = response.headers["location"].match(/(\d+)\.json/)[1].to_i return layer_index if response["status"].to_i == 201 end |
#attributes ⇒ Object
7 8 9 |
# File 'lib/geoiq/map.rb', line 7 def attributes %w{title description tags basemap extent layers} end |
#create(options = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/geoiq/map.rb', line 27 def create(={}) self.attributes.each do |a| .merge!({a => self.send(a)}) end response = request(:post, "/maps.json", {:query => }) id = response.headers["location"].match(/(\d+)\.json/)[1].to_i return find(id) end |
#delete ⇒ Object
45 46 47 48 49 |
# File 'lib/geoiq/map.rb', line 45 def delete requires_geoiq_id response = request(:delete, "/maps/#{self.geoiq_id}.json") return true if response["status"].to_i == 204 end |
#find(id, options = {}) ⇒ Object
21 22 23 24 25 |
# File 'lib/geoiq/map.rb', line 21 def find(id, ={}) response = request(:get, "/maps/#{id}.json", {:query => }) map = Geoiq::Map.parse(response, auth, {:geoiq_id => id}) map end |
#update(options = {}) ⇒ Object
39 40 41 42 43 |
# File 'lib/geoiq/map.rb', line 39 def update(={}) requires_geoiq_id response = request(:put, "/maps/#{self.geoiq_id}.json", {:query => }) return true if response["status"].to_i == 200 || response["status"].to_i == 201 end |