Module: StringWorkJustinewalt
- Defined in:
- lib/string_work_justinewalt.rb,
lib/string_work_justinewalt/version.rb
Defined Under Namespace
Modules: Greetings
Constant Summary collapse
- VERSION =
"0.2.0"
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.reversify(str) ⇒ Object
4 5 6 |
# File 'lib/string_work_justinewalt.rb', line 4 def self.reversify(str) str.split('').reverse.join('') end |
.spacify(str, spaces = 0) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/string_work_justinewalt.rb', line 17 def self.spacify(str, spaces = 0) new_string = str spaces.times do new_string = new_string.split('').join(' ') end new_string end |
Instance Method Details
#casify(str) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/string_work_justinewalt.rb', line 8 def 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 end |