Class: StaticGmaps::Marker

Inherits:
Object
  • Object
show all
Defined in:
lib/static_gmaps.rb

Overview

Constant Summary collapse

DEFAULT_LATITUDE =
nil
DEFAULT_LONGITUDE =
nil
DEFAULT_COLOR =
nil
DEFAULT_ALPHA_CHARACTER =
nil
VALID_COLORS =
[ :red, :green, :blue ]
VALID_ALPHA_CHARACTERS =
[ :a, :b, :c, :d, :e, :f, :g, :h, :i, :j, :k, :l, :m, :n, :o, :p, :q, :r, :s, :t, :u, :v, :w, :x, :y, :z ]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Marker

Returns a new instance of Marker.



125
126
127
128
129
130
# File 'lib/static_gmaps.rb', line 125

def initialize(options = {})
  self.latitude        = options[:latitude]        || DEFAULT_LATITUDE
  self.longitude       = options[:longitude]       || DEFAULT_LONGITUDE
  self.color           = options[:color]           || DEFAULT_COLOR
  self.alpha_character = options[:alpha_character] || DEFAULT_ALPHA_CHARACTER
end

Instance Attribute Details

#alpha_characterObject

Returns the value of attribute alpha_character.



120
121
122
# File 'lib/static_gmaps.rb', line 120

def alpha_character
  @alpha_character
end

#colorObject

Returns the value of attribute color.



120
121
122
# File 'lib/static_gmaps.rb', line 120

def color
  @color
end

#latitudeObject

Returns the value of attribute latitude.



120
121
122
# File 'lib/static_gmaps.rb', line 120

def latitude
  @latitude
end

#longitudeObject

Returns the value of attribute longitude.



120
121
122
# File 'lib/static_gmaps.rb', line 120

def longitude
  @longitude
end

Instance Method Details

#url_fragmentObject

Raises:

  • (MissingArgument)


152
153
154
155
156
157
158
159
# File 'lib/static_gmaps.rb', line 152

def url_fragment
  raise MissingArgument.new("Latitude must be set before a url_fragment can be generated for Marker.") if !latitude
  raise MissingArgument.new("Longitude must be set before a url_fragment can be generated for Marker.") if !longitude
  x  = "#{latitude},#{longitude}"
  x += ",#{color}" if color
  x += "#{alpha_character}" if alpha_character
  return x
end