Class: Pipl::API::Response::Location
- Inherits:
-
Object
- Object
- Pipl::API::Response::Location
- Defined in:
- lib/pipl/api/response/location.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#country ⇒ Object
readonly
Returns the value of attribute country.
-
#estimation ⇒ Object
readonly
Returns the value of attribute estimation.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
-
#initialize(location) ⇒ Location
constructor
A new instance of Location.
- #to_hash ⇒ Object (also: #to_h)
Constructor Details
#initialize(location) ⇒ Location
Returns a new instance of Location.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/pipl/api/response/location.rb', line 8 def initialize(location) @code = location["country"] if location["display"] && location["display"].include?(",") @state = location["display"].split(", ").first @country = location["display"].split(", ").last else @country = location["display"] end @estimation = location["estimated_percent"].to_f / 100 end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
5 6 7 |
# File 'lib/pipl/api/response/location.rb', line 5 def code @code end |
#country ⇒ Object (readonly)
Returns the value of attribute country.
5 6 7 |
# File 'lib/pipl/api/response/location.rb', line 5 def country @country end |
#estimation ⇒ Object (readonly)
Returns the value of attribute estimation.
6 7 8 |
# File 'lib/pipl/api/response/location.rb', line 6 def estimation @estimation end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
5 6 7 |
# File 'lib/pipl/api/response/location.rb', line 5 def state @state end |
Instance Method Details
#to_hash ⇒ Object Also known as: to_h
19 20 21 22 23 24 25 26 |
# File 'lib/pipl/api/response/location.rb', line 19 def to_hash { code: code, state: state, country: country, estimation: estimation } end |