lib/ahoy/deckhands/location_deckhand.rb in ahoy_matey-1.1.1 vs lib/ahoy/deckhands/location_deckhand.rb in ahoy_matey-1.2.0

- old
+ new

@@ -1,9 +1,8 @@ module Ahoy module Deckhands class LocationDeckhand - def initialize(ip) @ip = ip end def country @@ -12,18 +11,30 @@ def region location.try(:state).presence end + def postal_code + location.try(:postal_code).presence + end + def city location.try(:city).presence end + def latitude + location.try(:latitude).presence + end + + def longitude + location.try(:longitude).presence + end + protected def location - if !@checked + unless @checked @location = begin Geocoder.search(@ip).first rescue => e $stderr.puts e.message @@ -31,9 +42,8 @@ end @checked = true end @location end - end end end