class Pipl::API::Response::Person
Attributes
ages[R]
estimated_world_persons_count[R]
full_names[R]
gender[R]
locations[R]
name[R]
nicknames[R]
spellings[R]
translations[R]
Public Class Methods
new(data)
click to toggle source
# 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
Public Instance Methods
to_hash()
click to toggle source
# 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
Also aliased as: to_h
Private Instance Methods
convert_ages(list)
click to toggle source
# File lib/pipl/api/response/person.rb, line 54 def convert_ages(list) list.map { |age| Age.new(age) } end
convert_locations(list)
click to toggle source
# File lib/pipl/api/response/person.rb, line 50 def convert_locations(list) list.map { |location| Location.new(location) } end
convert_names(list)
click to toggle source
# File lib/pipl/api/response/person.rb, line 44 def convert_names(list) list.map do |part, names| names.map { |name| Name.new(part => name) } end.flatten end