Class: Smappy::Marker
Constant Summary collapse
- DEFAULT_IMAGE =
File.('../../../markers/marker.png', __FILE__)
Instance Attribute Summary collapse
-
#image ⇒ Object
Returns the value of attribute image.
-
#offset ⇒ Object
Returns the value of attribute offset.
Attributes inherited from Location
Instance Method Summary collapse
- #height ⇒ Object
-
#initialize(latitude, longitude) ⇒ Marker
constructor
A new instance of Marker.
-
#marker_image ⇒ Object
UNTESTED:.
- #position_on_map(map) ⇒ Object
- #width ⇒ Object
Methods inherited from Location
Constructor Details
#initialize(latitude, longitude) ⇒ Marker
Returns a new instance of Marker.
10 11 12 13 14 15 |
# File 'lib/smappy/marker.rb', line 10 def initialize(latitude, longitude) @image = DEFAULT_IMAGE @offset = [-(width / 2), -height].map(&:to_i) super end |
Instance Attribute Details
#image ⇒ Object
Returns the value of attribute image.
8 9 10 |
# File 'lib/smappy/marker.rb', line 8 def image @image end |
#offset ⇒ Object
Returns the value of attribute offset.
8 9 10 |
# File 'lib/smappy/marker.rb', line 8 def offset @offset end |
Instance Method Details
#height ⇒ Object
21 22 23 |
# File 'lib/smappy/marker.rb', line 21 def height marker_image.height end |
#marker_image ⇒ Object
UNTESTED:
32 33 34 35 36 |
# File 'lib/smappy/marker.rb', line 32 def marker_image @marker_image ||= ChunkyPNG::Image.from_datastream( ChunkyPNG::Datastream.from_io(open(image)) ) end |
#position_on_map(map) ⇒ Object
25 26 27 28 29 |
# File 'lib/smappy/marker.rb', line 25 def position_on_map(map) x, y = super [x + offset[0], y + offset[1]] end |
#width ⇒ Object
17 18 19 |
# File 'lib/smappy/marker.rb', line 17 def width marker_image.width end |