pipl-api 2.0.2 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pipl/api/response/person.rb +29 -21
- data/lib/pipl/api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee84b5c43a1fa477a8fb25be47bd90c3e767b539
|
4
|
+
data.tar.gz: 0840470db0a882c3a659cc05ba11152bacc97141
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51d274bbb869500305b5c234c3e9512afbcc9b321663210b7061c36043d1a4281dba2d0302660d7521ce09f8cd2fe39e4d7fdc090114ea1f08877f1d574708fe
|
7
|
+
data.tar.gz: a1e11a833c87ee7f0ffd1c64a219e50285f6616ed5966fb311c1a8f74fb25344494f8ad0dd60476ba6567ead259dbf7723954d44cafaac95b0007a6e25418bca
|
@@ -14,37 +14,45 @@ module Pipl
|
|
14
14
|
|
15
15
|
def initialize(data)
|
16
16
|
@name = Name.new(data["name"])
|
17
|
-
@full_names =
|
18
|
-
@nicknames =
|
19
|
-
@spellings =
|
20
|
-
@translations = data["translations"]
|
17
|
+
@full_names = convert_names(data["full_names"])
|
18
|
+
@nicknames = convert_names(data["nicknames"])
|
19
|
+
@spellings = convert_names(data["spellings"])
|
20
|
+
@translations = convert_names(data["translations"])
|
21
21
|
@gender = Gender.new(data["gender"])
|
22
|
-
@locations = data["top_locations"]
|
23
|
-
@ages = data["top_ages"]
|
22
|
+
@locations = convert_locations(data["top_locations"])
|
23
|
+
@ages = convert_locations(data["top_ages"])
|
24
24
|
@estimated_world_persons_count = data["estimated_world_persons_count"]
|
25
25
|
end
|
26
26
|
|
27
27
|
def to_hash
|
28
|
-
|
29
|
-
|
30
|
-
:
|
31
|
-
:
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end.inject(&:merge!)
|
28
|
+
{
|
29
|
+
name: name.to_hash,
|
30
|
+
full_names: full_names.map(&:to_hash),
|
31
|
+
nicknames: nicknames.map(&:to_hash),
|
32
|
+
spellings: spellings.map(&:to_hash),
|
33
|
+
translations: translations.map(&:to_hash),
|
34
|
+
gender: gender.to_hash,
|
35
|
+
locations: locations.map(&:to_hash),
|
36
|
+
ages: ages.map(&:to_hash),
|
37
|
+
estimated_world_persons_count: estimated_world_persons_count
|
38
|
+
}
|
40
39
|
end
|
41
40
|
alias_method :to_h, :to_hash
|
42
41
|
|
43
|
-
|
44
42
|
private
|
45
43
|
|
46
|
-
def
|
47
|
-
|
44
|
+
def convert_names(list)
|
45
|
+
list.map do |part, names|
|
46
|
+
names.map { |name| Name.new(part => name) }
|
47
|
+
end.flatten
|
48
|
+
end
|
49
|
+
|
50
|
+
def convert_locations(list)
|
51
|
+
list.map { |location| Location.new(location) }
|
52
|
+
end
|
53
|
+
|
54
|
+
def convert_ages(list)
|
55
|
+
list.map { |age| Age.new(age) }
|
48
56
|
end
|
49
57
|
end
|
50
58
|
end
|
data/lib/pipl/api/version.rb
CHANGED