pluralizer 0.0.4
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.
- data/lib/pluralizer.rb +40 -0
- metadata +47 -0
data/lib/pluralizer.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# The main Pluralizer class
|
2
|
+
class Pluralizer
|
3
|
+
|
4
|
+
# Examples:
|
5
|
+
# >> Pluralizer.pluralize(book)
|
6
|
+
# => books
|
7
|
+
#
|
8
|
+
# >> Pluralizer.pluralize(bunny)
|
9
|
+
# => bunnies
|
10
|
+
#
|
11
|
+
# @param [String] word to be pluralized
|
12
|
+
# @return [String] word in plural form
|
13
|
+
|
14
|
+
def self.pluralize(word)
|
15
|
+
if is_vowel(word[-2,1]) && word[-1,1] == "y"
|
16
|
+
puts word + "s"
|
17
|
+
elsif is_vowel(word[-2,1]) == false && word[-1,1] == "y"
|
18
|
+
puts word[0, word.length - 1] + "ies"
|
19
|
+
elsif is_vowel(word[-2,1]) && word[-1,1] == "o"
|
20
|
+
puts word + "s"
|
21
|
+
elsif is_vowel(word[-2,1]) == false && word[-1,1] == "o"
|
22
|
+
puts word + "es"
|
23
|
+
elsif word[-2,2] == "fe" || word[-1,1] == "f"
|
24
|
+
puts word[0, word.length - 1] + "ves"
|
25
|
+
elsif word[-1,1] == "s" || word[-2,2] == "ss" || word[-2,2] == "sh" || word[-2,2] == "ch" || word[-1,1] == "x" || word[-1,1] == "z"
|
26
|
+
puts word + "es"
|
27
|
+
else
|
28
|
+
puts word + "s"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.is_vowel(letter)
|
33
|
+
if letter == "a" || letter == "e" || letter == "i" || letter == "o" || letter == "u"
|
34
|
+
return true
|
35
|
+
else
|
36
|
+
return false
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pluralizer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Elyse Dougherty
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-01 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: A gem for basic English pluralization rules - Pluralizer.pluralize(scarf)
|
15
|
+
=> scarves
|
16
|
+
email: elysedougherty@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/pluralizer.rb
|
22
|
+
homepage: http://rubygems.org/gems/pluralizer
|
23
|
+
licenses: []
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
36
|
+
requirements:
|
37
|
+
- - ! '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 1.8.23
|
43
|
+
signing_key:
|
44
|
+
specification_version: 3
|
45
|
+
summary: A gem to pluralize your words
|
46
|
+
test_files: []
|
47
|
+
has_rdoc:
|