Class: Jologs::Jologize
- Inherits:
-
Object
- Object
- Jologs::Jologize
- Defined in:
- lib/jologs/jologize.rb
Constant Summary collapse
- @@dictionary =
nil
Class Method Summary collapse
- .dictionary ⇒ Object
- .jologize(str) ⇒ Object
- .load_dictionary!(file) ⇒ Object
- .translate(str) ⇒ Object
Class Method Details
.dictionary ⇒ Object
24 25 26 |
# File 'lib/jologs/jologize.rb', line 24 def dictionary @@dictionary end |
.jologize(str) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/jologs/jologize.rb', line 11 def jologize(str) result = str dictionary.each do |jolog_word, normal_word| begin # result = result.gsub(normal_word, jolog_word) result = result.gsub(Regexp.new("#{normal_word}", [Regexp::IGNORECASE, Regexp::MULTILINE]), jolog_word) rescue Exception => e puts "Halted on #{normal_word} #{jolog_word} : #{e.}" end end result end |
.load_dictionary!(file) ⇒ Object
28 29 30 |
# File 'lib/jologs/jologize.rb', line 28 def load_dictionary!(file) @@dictionary = YAML.load_file(file) end |
.translate(str) ⇒ Object
7 8 9 |
# File 'lib/jologs/jologize.rb', line 7 def translate(str) jologize(str) end |