Module: StrHelperVp
- Defined in:
- lib/str_helper_vp.rb,
lib/str_helper_vp/version.rb
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
- .casify(str) ⇒ Object
-
.reversify(str) ⇒ Object
Your code goes here…
- .spacify(str, space = 0) ⇒ Object
Class Method Details
.casify(str) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/str_helper_vp.rb', line 10 def self.casify(str) # randomly choose uppercase or lowercase letters returned: to_case = [:upcase, :downcase] arr = str.split('') arr.each_with_index do |letter, i| this_case = to_case.sample # if you have a symbol that represents a method, you can arr[i]= letter.send(this_case) end arr.join('') end |
.reversify(str) ⇒ Object
Your code goes here…
6 7 8 |
# File 'lib/str_helper_vp.rb', line 6 def self.reversify(str) str.split('').reverse.join('') end |
.spacify(str, space = 0) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/str_helper_vp.rb', line 22 def self.spacify(str, space=0) # put that many spaces between each thing spaces.times do str = str.split('').join(' ') end str end |