Class: Masklen::Location
- Inherits:
-
Struct
- Object
- Struct
- Masklen::Location
- Defined in:
- lib/masklen/types.rb
Overview
Geographic location data for an IP address.
Instance Attribute Summary collapse
-
#city ⇒ Object
Returns the value of attribute city.
-
#country ⇒ Object
Returns the value of attribute country.
-
#country_code ⇒ Object
Returns the value of attribute country_code.
-
#latitude ⇒ Object
Returns the value of attribute latitude.
-
#longitude ⇒ Object
Returns the value of attribute longitude.
-
#postal_code ⇒ Object
Returns the value of attribute postal_code.
-
#region ⇒ Object
Returns the value of attribute region.
-
#timezone ⇒ Object
Returns the value of attribute timezone.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Build a Location from a parsed JSON hash.
Instance Attribute Details
#city ⇒ Object
Returns the value of attribute city
3 4 5 |
# File 'lib/masklen/types.rb', line 3 def city @city end |
#country ⇒ Object
Returns the value of attribute country
3 4 5 |
# File 'lib/masklen/types.rb', line 3 def country @country end |
#country_code ⇒ Object
Returns the value of attribute country_code
3 4 5 |
# File 'lib/masklen/types.rb', line 3 def country_code @country_code end |
#latitude ⇒ Object
Returns the value of attribute latitude
3 4 5 |
# File 'lib/masklen/types.rb', line 3 def latitude @latitude end |
#longitude ⇒ Object
Returns the value of attribute longitude
3 4 5 |
# File 'lib/masklen/types.rb', line 3 def longitude @longitude end |
#postal_code ⇒ Object
Returns the value of attribute postal_code
3 4 5 |
# File 'lib/masklen/types.rb', line 3 def postal_code @postal_code end |
#region ⇒ Object
Returns the value of attribute region
3 4 5 |
# File 'lib/masklen/types.rb', line 3 def region @region end |
#timezone ⇒ Object
Returns the value of attribute timezone
3 4 5 |
# File 'lib/masklen/types.rb', line 3 def timezone @timezone end |
Class Method Details
.from_hash(hash) ⇒ Object
Build a Location from a parsed JSON hash. Returns nil if hash is nil.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/masklen/types.rb', line 15 def self.from_hash(hash) return nil if hash.nil? new( city: hash["city"], region: hash["region"], country: hash["country"], country_code: hash["country_code"], latitude: hash["latitude"], longitude: hash["longitude"], postal_code: hash["postal_code"], timezone: hash["timezone"] ) end |