Class: E2SW
- Inherits:
-
Object
- Object
- E2SW
- Defined in:
- lib/e2sw.rb
Class Method Summary collapse
- .inw(search, replace) ⇒ Object
- .inw_not(search, replace) ⇒ Object
- .niw(search, replace) ⇒ Object
- .nw(search, replace) ⇒ Object
- .to_sw(string) ⇒ Object
- .wc(search, replace) ⇒ Object
Class Method Details
.inw(search, replace) ⇒ Object
41 42 43 |
# File 'lib/e2sw.rb', line 41 def self.inw(search,replace) @string.gsub!(/(\w+?)#{search}(\w+)?/,"\\1#{replace}\\2") end |
.inw_not(search, replace) ⇒ Object
45 46 47 |
# File 'lib/e2sw.rb', line 45 def self.inw_not(search,replace) @string.gsub!(/(\w+?)#{search}(?=[^A-Za-z']|$)/,"\\1#{replace}\\2") end |
.niw(search, replace) ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/e2sw.rb', line 49 def self.niw(search,replace) if @string =~ /(^| )#{search}/ @string.gsub!(/(^| )#{search}/,"\\1#{replace}") elsif @string =~ /#{search}( |$)/ unless @string =~ /#{search}{2}/ puts "im here" @string.gsub!(/#{search}( |$)/,"#{replace}\\1") end end end |
.nw(search, replace) ⇒ Object
37 38 39 |
# File 'lib/e2sw.rb', line 37 def self.nw(search,replace) @string.gsub!(/#{search}(?=[^A-Za-z'])/,replace) end |
.to_sw(string) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/e2sw.rb', line 2 def self.to_sw(string) @string = string @string.gsub!(/an/,"un") @string.gsub!(/An/,"Un") @string.gsub!(/au/,"oo") @string.gsub!(/Au/,"Oo") wc("a","e") wc("A","E") inw("ew","oo") inw_not("e","e-a") nw("en","ee") niw("e","i") niw("E","I") inw("f","ff") inw("ir","ur") inw("i","ee") inw("ow","oo") niw("o","oo") niw("O","Oo") niw("tion","shun") @string.gsub!(/the( |$)/,"zee\\1") @string.gsub!(/The( |$)/,"Zee\\1") nw("th","t") inw("u","oo") @string.gsub!(/v/,"f") @string.gsub!(/V/,"F") @string.gsub!(/w/,"v") @string.gsub!(/W/,"v") return @string end |
.wc(search, replace) ⇒ Object
33 34 35 |
# File 'lib/e2sw.rb', line 33 def self.wc(search,replace) @string.gsub!(/#{search}(?=[A-Za-z'])/,replace) end |