Class: Prudding

Inherits:
Object
  • Object
show all
Defined in:
lib/prudding.rb

Instance Method Summary collapse

Constructor Details

#initialize(string) ⇒ Prudding

Returns a new instance of Prudding.



2
3
4
# File 'lib/prudding.rb', line 2

def initialize(string)
  @words = string.split(' ')
end

Instance Method Details

#to_pruddingObject



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/prudding.rb', line 6

def to_prudding
  @words.map do |w|
    if (idx = w.chars.index { |c| c =~ /[aeiou]/ }) && w.length > 3
      if idx > 0
        w.chars.insert(idx, "r").join('')
      else
        w
      end
    else
      w
    end
  end.join(" ")
end