name_abbr 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/lib/name_abbr.rb +9 -4
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
!binary "U0hBMQ==":
|
|
3
3
|
metadata.gz: !binary |-
|
|
4
|
-
|
|
4
|
+
MGJmYjQ4MWRjZGJjNDFkMWM0MDJjMmVkMTE0MWZmMDIzNTk2OWYyZA==
|
|
5
5
|
data.tar.gz: !binary |-
|
|
6
|
-
|
|
6
|
+
MTRkYjhmOWE5OTk0Y2I3MGU4MTE2OTYyYWVlNjc0MmJiMzMxNjdhOA==
|
|
7
7
|
SHA512:
|
|
8
8
|
metadata.gz: !binary |-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
NTgwMmI0ZDU5MzRiMmVhMzQ0NjYzMzliMWM4YTc3MjdiM2UzNTI4NDQyOTE2
|
|
10
|
+
NDM5NmY5MzExZmVjZjczZDQ3YjRhM2U1NDYwZmIwYzM2OTczZWUzNWJiNmMw
|
|
11
|
+
YzdjMjE5ODhhY2JlYjMyY2ZlMmE5ZGM3MmQ5M2Y3ZjRkOGRkOTY=
|
|
12
12
|
data.tar.gz: !binary |-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
YTY2NTY0NTM3YTBhMDhjYTkwZTRmMGY2YzA2NGMyYmY3NWQ4ZGYxMjY5Mjdk
|
|
14
|
+
NWI1MWVlOWYzYzNmNmQwN2VkZmZjMjYxZjYyNzg4MzEzYWU0YTQ5ZTdlNTRh
|
|
15
|
+
ODZmNzcwMGVlMzZjNTA1MjAxMDVlMjQwYTE0ZTdjZWYxOGZjN2I=
|
data/lib/name_abbr.rb
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
class NameAbbr
|
|
2
2
|
def self.abbr_name(first_name, last_name)
|
|
3
|
-
|
|
3
|
+
first_name = normalize(first_name)
|
|
4
|
+
last_name = normalize(last_name)
|
|
5
|
+
|
|
6
|
+
unless last_name.nil?
|
|
4
7
|
[first_name, last_name[0]].join(' ') + "."
|
|
5
8
|
else
|
|
6
9
|
first_name
|
|
@@ -8,7 +11,9 @@ class NameAbbr
|
|
|
8
11
|
end
|
|
9
12
|
|
|
10
13
|
def self.abbr_full_name(fullname)
|
|
11
|
-
|
|
14
|
+
fullname = normalize(fullname)
|
|
15
|
+
|
|
16
|
+
unless fullname.match(/ /).nil?
|
|
12
17
|
parts = fullname.split(' ')
|
|
13
18
|
[parts[0], parts[1][0]].join(' ') + "."
|
|
14
19
|
else
|
|
@@ -17,7 +22,7 @@ class NameAbbr
|
|
|
17
22
|
end
|
|
18
23
|
|
|
19
24
|
private
|
|
20
|
-
def self.
|
|
21
|
-
|
|
25
|
+
def self.normalize(input)
|
|
26
|
+
input.to_s.strip
|
|
22
27
|
end
|
|
23
28
|
end
|