Class: String

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

Instance Method Summary collapse

Instance Method Details

#rungeObject



16
17
18
# File 'lib/runge/string.rb', line 16

def runge
  split(/(\W)/).map(&:runge_string).join
end

#runge_stringObject

munge each string



3
4
5
6
7
8
9
10
11
12
13
14
# 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