Class: Pipl::API::Response::Age

Inherits:
Object
  • Object
show all
Defined in:
lib/pipl/api/response/age.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#estimationObject (readonly)

Returns the value of attribute estimation.



6
7
8
# File 'lib/pipl/api/response/age.rb', line 6

def estimation
  @estimation
end

#fromObject (readonly)

Returns the value of attribute from.



5
6
7
# File 'lib/pipl/api/response/age.rb', line 5

def from
  @from
end

#toObject (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_hashObject 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_rangeObject



14
15
16
# File 'lib/pipl/api/response/age.rb', line 14

def to_range
  @from..@to
end