Class: Vfrmap
- Inherits:
-
Object
- Object
- Vfrmap
- Includes:
- Padrino::Helpers::TagHelpers
- Defined in:
- lib/vfrmap.rb,
lib/vfrmap/version.rb
Defined Under Namespace
Classes: Location
Constant Summary collapse
- DEFAULT_OPTIONS =
{ type: 'vfrc', zoom: 10, width: 350, height: 350, class: nil, alt: nil }
- VERSION =
"1.1.0"
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(location_string, options = {}) ⇒ Vfrmap
constructor
A new instance of Vfrmap.
- #to_base64_jpg ⇒ Object
- #to_html ⇒ Object
- #to_jpg ⇒ Object
- #uri ⇒ Object (also: #src)
Constructor Details
#initialize(location_string, options = {}) ⇒ Vfrmap
Returns a new instance of Vfrmap.
23 24 25 26 27 |
# File 'lib/vfrmap.rb', line 23 def initialize(location_string,={}) @location = Location.factory(location_string) raise 'Invalid location' unless @location @options = DEFAULT_OPTIONS.merge() end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
21 22 23 |
# File 'lib/vfrmap.rb', line 21 def @options end |
Instance Method Details
#to_base64_jpg ⇒ Object
44 45 46 |
# File 'lib/vfrmap.rb', line 44 def to_base64_jpg Base64.encode64(to_jpg) end |
#to_html ⇒ Object
36 37 38 |
# File 'lib/vfrmap.rb', line 36 def to_html tag(:img, src: src, class: @options[:class], alt: @options[:alt]) end |
#to_jpg ⇒ Object
40 41 42 |
# File 'lib/vfrmap.rb', line 40 def to_jpg open(uri).read end |
#uri ⇒ Object Also known as: src
29 30 31 32 33 |
# File 'lib/vfrmap.rb', line 29 def uri URI::HTTP .build(host: 'vfrmap.com', path: '/api', query: query_params) .to_s end |