Class: Mapbox::Image
Overview
Image class
Instance Attribute Summary
Attributes inherited from Base
#access_token, #access_token_secret, #lat, #lon, #map_option, #map_type, #mapid, #overlays, #x, #y, #z, #zoom
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Image
constructor
A new instance of Image.
- #parameters_check ⇒ Object
- #response ⇒ Object
Methods inherited from Base
#base_url, #connection, #llz, #wh
Constructor Details
#initialize(opts = {}) ⇒ Image
Returns a new instance of Image.
7 8 9 10 11 12 13 14 |
# File 'lib/mapbox/image.rb', line 7 def initialize(opts = {}) super(opts) @map_type ||= 'png' @llz = llz @wh = wh parameters_check end |
Instance Method Details
#parameters_check ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/mapbox/image.rb', line 16 def parameters_check super fail ArgumentError, ':lon must be between -180 to 180' unless (-180..180).to_a.include?(@lon) fail ArgumentError, ':lat must be between -85 to 85' unless (-85..85).to_a.include?(@lat) fail ArgumentError, ':zoom must be between 0 to 15' unless (0..15).to_a.include?(@zoom) end |
#response ⇒ Object
26 27 28 29 30 |
# File 'lib/mapbox/image.rb', line 26 def response ::Tempfile.open("foo.#{@map_type}") do |r| r.write get.data[:body] end end |