Module: Owoify
- Defined in:
- lib/owoify_rb.rb
Overview
Owoify module is the main module where owoify function lies in. Since owoify is literally just a function, users are expected to invoke owoify by calling Owoify.owoify().
Class Method Summary collapse
-
.owoify(source, level = :owo) ⇒ String
The main entry point of the owoify function.
Class Method Details
.owoify(source, level = :owo) ⇒ String
The main entry point of the owoify function. Pass in the source string and the desired owoify level.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/owoify_rb.rb', line 15 def self.owoify(source, level = :owo) word_matches = source.scan(/[^\s]+/).flatten space_matches = source.scan(/\s+/).flatten words = word_matches.map { |x| Word.new(x) } spaces = space_matches.map { |x| Word.new(x) } words.map! do |w| SPECIFIC_WORD_MAPPING_LIST.each do |f| w = f.call(w) end case level when :owo OWO_MAPPING_LIST.each do |f| w = f.call(w) end when :uwu UWU_MAPPING_LIST.each do |f| w = f.call(w) end OWO_MAPPING_LIST.each do |f| w = f.call(w) end when :uvu UVU_MAPPING_LIST.each do |f| w = f.call(w) end UWU_MAPPING_LIST.each do |f| w = f.call(w) end OWO_MAPPING_LIST.each do |f| w = f.call(w) end else raise ArgumentError, 'The specified owoify level is not supported.' end w end result = interleave_arrays(words, spaces) result_strings = result.map(&:to_s) result_strings.join end |