Class: GoogleStaticMapsHelper::Location

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

Overview

Represents a location with lat and lng values.

This classed is used internally to back up Markers’ location and Paths’ points.

Defined Under Namespace

Classes: NoLatKey, NoLatMethod, NoLngKey, NoLngMethod

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Location

:call-seq:

new(location_object_or_options, *args)

Creates a new Location which is used by Marker and Path object to represent it’s locations.

:args: Either a location which responds to lat or lng, or a Hash which has :lat and :lng keys.

Raises:

  • (ArgumentError)


24
25
26
27
28
29
30
31
32
# File 'lib/google_static_maps_helper/location.rb', line 24

def initialize(*args)
  raise ArgumentError, "Must have some arguments." if args.length == 0
  
  if args.first.is_a? Hash
    extract_location_from_hash!(args.first)
  else
    extract_location_from_object(args.shift)
  end
end

Instance Attribute Details

#latObject

Returns the value of attribute lat.



14
15
16
# File 'lib/google_static_maps_helper/location.rb', line 14

def lat
  @lat
end

#lngObject

Returns the value of attribute lng.



14
15
16
# File 'lib/google_static_maps_helper/location.rb', line 14

def lng
  @lng
end

Instance Method Details

#to_urlObject

Returning the location as a string “lat,lng”



37
38
39
# File 'lib/google_static_maps_helper/location.rb', line 37

def to_url # :nodoc:
  [lat, lng].join(',')
end