name_splitter 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/name_splitter.rb +13 -4
- data/lib/name_splitter/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: 1564e0d6f7a81a05f7c77926c9548115b5f49974
|
4
|
+
data.tar.gz: 82c6d53e108581d3e3c071efd83756a4c8924d82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2e08535bac76dc5094cff67036b27e4dd58644ee6c4e1011e91f5dad3707a65bd4057654b9c96f61f0c0d11c074a421a1403db1c30d280c174a5cd7c91be6d7
|
7
|
+
data.tar.gz: 06028d326a852f8f10f8d0eafa40659d90f9965500a6a762478a8c0068b41e50fc0db6c8e539bf43a7caff2e75d4d77b521dc7d6bc5ac03a18e4906b8545f505
|
data/lib/name_splitter.rb
CHANGED
@@ -45,7 +45,7 @@ module NameSplitter
|
|
45
45
|
self.last_name = name_arr.shift
|
46
46
|
else
|
47
47
|
self.first_name = name_arr.shift(number_of_first_names(name_arr)).join(" ")
|
48
|
-
self.middle_name = name_arr.shift
|
48
|
+
self.middle_name = name_arr.shift(number_of_middle_names(name_arr)).join(" ")
|
49
49
|
self.last_name_check(name_arr)
|
50
50
|
end
|
51
51
|
end
|
@@ -62,14 +62,23 @@ module NameSplitter
|
|
62
62
|
|
63
63
|
private
|
64
64
|
|
65
|
-
def
|
65
|
+
def number_of_middle_names(name_arr)
|
66
|
+
# if the first and last names have already been assigned, assume the
|
67
|
+
# rest of the name is a middle name
|
68
|
+
if !first_name.empty? && !last_name.empty?
|
69
|
+
return name_arr.length
|
70
|
+
end
|
71
|
+
|
66
72
|
#checks whether the array of names passed in contains a likely middle name
|
67
|
-
(name_arr.length ==
|
68
|
-
(name_arr.length == 2 &&
|
73
|
+
if (name_arr.length == 2 &&
|
69
74
|
!(contains_suffix(name_arr) || contains_last_name_prefix(name_arr))) ||
|
70
75
|
(name_arr.length == 3 &&
|
71
76
|
!(contains_suffix(name_arr) && contains_last_name_prefix(name_arr))) ||
|
72
77
|
name_arr.length > 3
|
78
|
+
return 1
|
79
|
+
end
|
80
|
+
|
81
|
+
return 0
|
73
82
|
end
|
74
83
|
|
75
84
|
def number_of_salutations(name_arr)
|