Module: WordifyStuckiest

Defined in:
lib/wordify_stuckiest.rb,
lib/wordify_stuckiest/version.rb

Constant Summary collapse

VERSION =
"1.1.0"

Class Method Summary collapse

Class Method Details

.casify(str) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/wordify_stuckiest.rb', line 10

def self.casify(str)
  to_case = [:upcase, :downcase]
  arr = str.split("")
  arr.each_with_index do |letter, i|
    this_case = to_case[rand(2)]
    arr[i] = letter.send(this_case)
  end
  arr.join("")
end

.reversify(str) ⇒ Object



6
7
8
# File 'lib/wordify_stuckiest.rb', line 6

def self.reversify(str)
  str.split("").reverse.join('')
end

.spacify(str, spaces = 0) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/wordify_stuckiest.rb', line 20

def self.spacify(str, spaces = 0)
  new_string = str
  spaces.times do
    new_string = new_string.split("").join(" ")
  end
  new_string
end