Sha256: 1590cca73384fff2f8f0eada1f985e609162b5476219348dcdbb09d193ec027a

Contents?: true

Size: 1004 Bytes

Versions: 1

Compression:

Stored size: 1004 Bytes

Contents

require 'open-uri'
require 'json'
require 'csv'
require 'active_support/all'
require 'zip'

module GeoNamesAPI

  mattr_accessor :url
  self.url = 'http://api.geonames.org/'

  mattr_accessor :lang
  self.lang = :en
  
  mattr_accessor :username
  self.username = 'demo'

  mattr_accessor :token
  self.token = nil

  mattr_accessor :style
  self.style = :full

  mattr_accessor :logger
  self.logger = nil

  mattr_accessor :retries
  self.retries = 5

  mattr_accessor :max_sleep_time_between_retries
  self.max_sleep_time_between_retries = 10

  def self.params
    {
      lang: lang,
      username: username,
      token: token,
      style: style
    }.delete_if{ |k, v| v.blank? }
  end
    
end

require 'geonames_api/version' # explicit require version file because it doesn't contain any class which can be autoload
Dir[File.dirname(__FILE__) + '/geonames_api/*.rb'].each do |file|
  tgt = File.basename(file, File.extname(file))
  GeoNamesAPI.autoload tgt.camelize, "geonames_api/#{tgt}"
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
geonames_api-0.1.6 lib/geonames_api.rb