class Prudding

Constants

BEN_WORD
ING_WORD
PLE_WORD

Public Class Methods

new(string) click to toggle source
# File lib/prudding.rb, line 2
def initialize(string)
  @words = string.split(' ')
end

Public Instance Methods

to_prudding() click to toggle source
# File lib/prudding.rb, line 6
def to_prudding
  @words.map { |word| process(word) }.join(" ")
end

Private Instance Methods

process(word) click to toggle source
# File lib/prudding.rb, line 16
def process(word)
  return word 

  if (match = word.match(PLE_WORD))
    captures = match.captures.clone
    captures[1] = 're'
    captures.join('')
  elsif (match = word.match(BEN_WORD))
    match.captures.insert(1, 'r').join('')
  elsif (match = word.match(ING_WORD))
    match.captures.insert(1, 'r').join('')
  else
    word
  end
end