Class: KondutoGeolocation

Inherits:
Object
  • Object
show all
Defined in:
lib/konduto-ruby/konduto_geolocation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ KondutoGeolocation

Returns a new instance of KondutoGeolocation.


4
5
6
7
8
9
10
# File 'lib/konduto-ruby/konduto_geolocation.rb', line 4

def initialize(*args)
  unless args[0].nil?
    args[0].each do |k,v|
      instance_variable_set("@#{k}", v) unless v.nil?
    end
  end
end

Instance Attribute Details

#cityObject

Returns the value of attribute city


2
3
4
# File 'lib/konduto-ruby/konduto_geolocation.rb', line 2

def city
  @city
end

#countryObject

Returns the value of attribute country


2
3
4
# File 'lib/konduto-ruby/konduto_geolocation.rb', line 2

def country
  @country
end

#stateObject

Returns the value of attribute state


2
3
4
# File 'lib/konduto-ruby/konduto_geolocation.rb', line 2

def state
  @state
end

Instance Method Details

#to_hashObject


12
13
14
15
16
17
18
19
# File 'lib/konduto-ruby/konduto_geolocation.rb', line 12

def to_hash
  hash = {
      city: self.city,
      state: self.state,
      country: self.country
  }
  KondutoUtils.remove_nil_keys_from_hash(hash)
end

#to_jsonObject


21
22
23
# File 'lib/konduto-ruby/konduto_geolocation.rb', line 21

def to_json
  self.to_hash.to_json
end