Class: Pipl::API::Response::Person

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Person

Returns a new instance of Person.



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/pipl/api/response/person.rb', line 15

def initialize(data)
  @name = Name.new(data["name"])
  @full_names = convert_names(data["full_names"])
  @nicknames = convert_names(data["nicknames"])
  @spellings = convert_names(data["spellings"])
  @translations = convert_names(data["translations"])
  @gender = Gender.new(data["gender"])
  @locations = convert_locations(data["top_locations"])
  @ages = convert_locations(data["top_ages"])
  @estimated_world_persons_count = data["estimated_world_persons_count"]
end

Instance Attribute Details

#agesObject (readonly)

Returns the value of attribute ages.



11
12
13
# File 'lib/pipl/api/response/person.rb', line 11

def ages
  @ages
end

#estimated_world_persons_countObject (readonly)

Returns the value of attribute estimated_world_persons_count.



13
14
15
# File 'lib/pipl/api/response/person.rb', line 13

def estimated_world_persons_count
  @estimated_world_persons_count
end

#full_namesObject (readonly)

Returns the value of attribute full_names.



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

def full_names
  @full_names
end

#genderObject (readonly)

Returns the value of attribute gender.



12
13
14
# File 'lib/pipl/api/response/person.rb', line 12

def gender
  @gender
end

#locationsObject (readonly)

Returns the value of attribute locations.



10
11
12
# File 'lib/pipl/api/response/person.rb', line 10

def locations
  @locations
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#nicknamesObject (readonly)

Returns the value of attribute nicknames.



7
8
9
# File 'lib/pipl/api/response/person.rb', line 7

def nicknames
  @nicknames
end

#spellingsObject (readonly)

Returns the value of attribute spellings.



8
9
10
# File 'lib/pipl/api/response/person.rb', line 8

def spellings
  @spellings
end

#translationsObject (readonly)

Returns the value of attribute translations.



9
10
11
# File 'lib/pipl/api/response/person.rb', line 9

def translations
  @translations
end

Instance Method Details

#to_hashObject Also known as: to_h



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/pipl/api/response/person.rb', line 27

def to_hash
  {
    name: name.to_hash,
    full_names: full_names.map(&:to_hash),
    nicknames: nicknames.map(&:to_hash),
    spellings: spellings.map(&:to_hash),
    translations: translations.map(&:to_hash),
    gender: gender.to_hash,
    locations: locations.map(&:to_hash),
    ages: ages.map(&:to_hash),
    estimated_world_persons_count: estimated_world_persons_count
  }
end