class GmapsGeocoding::Config
Configuration class for GmapsGeocoding
API.
Constants
- DEFAULT_CONFIG
Default configuration values
Public Class Methods
new(opts = {})
click to toggle source
# File lib/gmaps_geocoding/config.rb, line 21 def initialize(opts = {}) opts = DEFAULT_CONFIG.merge(opts) VALID_KEYS.each do |k, _| next unless VALID_KEYS.include?(k) val = ENV["GOOGLE_MAPS_GEOCODING_#{k.to_s.upcase}"] || opts.delete(k) send("#{k}=", val) if val end end
Public Instance Methods
json_format?()
click to toggle source
Check if the output format of the query is set to json
@return [true, false] Return true or false
# File lib/gmaps_geocoding/config.rb, line 40 def json_format? 'json'.freeze.eql?(output) end
valid?()
click to toggle source
Check if the configuration object is valid
@return [true, false] Return true or false
# File lib/gmaps_geocoding/config.rb, line 33 def valid? query_valid? && output_param_valid? end
xml_format?()
click to toggle source
Check if the output format of the query is set to xml
@return [true, false] Return true or false
# File lib/gmaps_geocoding/config.rb, line 47 def xml_format? 'xml'.freeze.eql?(output) end
Private Instance Methods
output_param_valid?()
click to toggle source
Check if the output format is valid
According to the specifications: {developers.google.com/maps/documentation/geocoding/#GeocodingResponses}
# File lib/gmaps_geocoding/config.rb, line 65 def output_param_valid? %w(json xml).include?(output) end
query_valid?()
click to toggle source
Check if the query is valid
According to the specifications: {developers.google.com/maps/documentation/geocoding/#GeocodingRequests}
# File lib/gmaps_geocoding/config.rb, line 56 def query_valid? (address && latlng.nil?) || (latlng && address.nil?) || !components.nil? end