Module: TzPickup

Defined in:
lib/tz_pickup.rb,
lib/tz_pickup/cli.rb,
lib/tz_pickup/tz_tree.rb,
lib/tz_pickup/version.rb

Defined Under Namespace

Classes: CLI, TzTree

Constant Summary collapse

VERSION =
"0.0.1"

Class Method Summary collapse

Class Method Details

.rootObject

Method return proper root path either for rails environment or for tests

Input: none Output: root path



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

def self.root 
  (defined?(Rails) && !Rails.root.nil?) ? Rails.root : File.expand_path('.')
end

.tz_pickup(lat, lon) ⇒ Object

Method returns timezone based on location that is the nearest to lat and lon

Input: latitude and longitude Output: international timezone name



25
26
27
28
# File 'lib/tz_pickup.rb', line 25

def self.tz_pickup(lat, lon)
  tree = TzTree.get_tree(root)
  tree.find_tz(lat, lon)
end