Class: VWorkApp::Location

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#attributes, #attributes=, #attributes_eql?, hattr_accessor, hattr_reader, hattr_writer, hattrs, #hattrs, #initialize, #read_attributes, #read_attributes=, read_hattrs, #read_hattrs, #validate_and_raise, #write_attributes, #write_attributes=, #write_hattrs, write_hattrs

Constructor Details

This class inherits a constructor from VWorkApp::Base

Class Method Details

.from_address(address, options = {}) ⇒ Object



6
7
8
9
10
11
# File 'lib/vworkapp_ruby/location.rb', line 6

def self.from_address(address, options = {})
  location_options = { :region => :us }.reverse_merge(options)
  
  loc = Location.geocode(address, location_options).first.geometry.location
  self.new(:formatted_address => address, :lat => loc.lat, :lng => loc.lng)
end

Instance Method Details

#==(other) ⇒ Object



13
14
15
# File 'lib/vworkapp_ruby/location.rb', line 13

def ==(other)
  attributes_eql?(other, :lat, :lng)
end