Class: Pipl::API::Response::Age
- Inherits:
-
Object
- Object
- Pipl::API::Response::Age
- Defined in:
- lib/pipl/api/response/age.rb
Instance Attribute Summary collapse
-
#estimation ⇒ Object
readonly
Returns the value of attribute estimation.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
-
#initialize(age) ⇒ Age
constructor
A new instance of Age.
- #to_hash ⇒ Object (also: #to_h)
- #to_range ⇒ Object
Constructor Details
#initialize(age) ⇒ Age
Returns a new instance of Age.
8 9 10 11 12 |
# File 'lib/pipl/api/response/age.rb', line 8 def initialize(age) @from = age["from_age"] @to = age["to_age"] @estimation = age["estimated_percent"].to_f / 100 end |
Instance Attribute Details
#estimation ⇒ Object (readonly)
Returns the value of attribute estimation.
6 7 8 |
# File 'lib/pipl/api/response/age.rb', line 6 def estimation @estimation end |
#from ⇒ Object (readonly)
Returns the value of attribute from.
5 6 7 |
# File 'lib/pipl/api/response/age.rb', line 5 def from @from end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
5 6 7 |
# File 'lib/pipl/api/response/age.rb', line 5 def to @to end |
Instance Method Details
#to_hash ⇒ Object Also known as: to_h
18 19 20 21 22 23 |
# File 'lib/pipl/api/response/age.rb', line 18 def to_hash { range: to_range, estimation: estimation } end |
#to_range ⇒ Object
14 15 16 |
# File 'lib/pipl/api/response/age.rb', line 14 def to_range @from..@to end |