class String

Public Instance Methods

runge() click to toggle source
# File lib/runge/string.rb, line 16
def runge
  split(/(\W)/).map(&:runge_string).join
end
runge_string() click to toggle source

munge each string

# File lib/runge/string.rb, line 3
def runge_string
  # don't mutate short strings
  if length == 1 || length == 2
    self
  # don't mutate integers
  elsif to_i > 0
    self
  # munge each string
  else
    split('').each_with_index { |x, i| x.succ! if i.odd? }.join
  end
end