Module: S5nN2e
- Defined in:
- lib/s5n_n2e.rb,
lib/s5n_n2e/version.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
Class Method Details
.convert(word = nil) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/s5n_n2e.rb', line 31 def self.convert(word = nil) if word.size > 2 then num = word.size - 2 word[0] + num.to_s + word[-1] else word end end |
.shorten(word = nil) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/s5n_n2e.rb', line 7 def self.shorten(word = nil) if word.include?(".") then word.gsub!(/\./, " .") end if word.include?(",") then word.gsub!(/\,/, " ,") end if word.include?(" ") then words = word.split(" ") result = words.collect{|w| convert(w)}.join(" ") if word.include?(".") then result.gsub!(/\s\./, ".") end if word.include?(",") then result.gsub!(/\s\,/, ",") else result end else convert(word) end end |