Class: Google::Maps::Static::Items::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/google/maps/static/items/base.rb

Direct Known Subclasses

Markers, Path, Visible

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Base

Returns a new instance of Base.

Raises:



13
14
15
16
17
18
19
# File 'lib/google/maps/static/items/base.rb', line 13

def initialize *args
  @options = args.extract_options!
  
  raise GMapper::Error, "One or more locations is required for the feature." if args.empty?
  @locations = args
  @item = self.class.name.split('::').last.downcase
end

Instance Method Details

#to_sObject

Raises:



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/google/maps/static/items/base.rb', line 21

def to_s
  raise GMapper::Error, "@item cannot be nil!" if @item.nil?
  
  result = @options.map do |key, value|
    "#{key.to_s}:#{value.to_s}|"
  end.join
  
  result += @locations.map do |loc|
    loc.is_a?(Array) ? loc.join(',') : loc.to_s
  end.join('|')
  
  "#{@item}=#{result}"
end