Class: KondutoGeolocation
- Inherits:
-
Object
- Object
- KondutoGeolocation
- Defined in:
- lib/konduto-ruby/konduto_geolocation.rb
Instance Attribute Summary collapse
-
#city ⇒ Object
Returns the value of attribute city.
-
#country ⇒ Object
Returns the value of attribute country.
-
#state ⇒ Object
Returns the value of attribute state.
Instance Method Summary collapse
-
#initialize(*args) ⇒ KondutoGeolocation
constructor
A new instance of KondutoGeolocation.
- #to_hash ⇒ Object
- #to_json ⇒ Object
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
#city ⇒ Object
Returns the value of attribute city.
2 3 4 |
# File 'lib/konduto-ruby/konduto_geolocation.rb', line 2 def city @city end |
#country ⇒ Object
Returns the value of attribute country.
2 3 4 |
# File 'lib/konduto-ruby/konduto_geolocation.rb', line 2 def country @country end |
#state ⇒ Object
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_hash ⇒ Object
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_json ⇒ Object
21 22 23 |
# File 'lib/konduto-ruby/konduto_geolocation.rb', line 21 def to_json self.to_hash.to_json end |