Module: WordifyBecz

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

Overview

any time you add more code to your gem, must run in terminal: gem build wordify_becz.gemspec

Constant Summary collapse

VERSION =

major.minor.patch

"0.2.0"

Class Method Summary collapse

Class Method Details

.casify(str) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/wordify_becz.rb', line 13

def self.casify(str)
  the_case = [:downcase, :upcase]
  letters = str.split("") #splits string into an array of letters 
  letters.each_with_index do |letter, i|
    this_case = the_case.sample
    letters[i] = letter.send(this_case) # .send: calls a method. it's sending a method to the letter we are passing it. 
  end 
  letters.join('') # .join is putting letters(which is an array, back into a string)
end

.random_dayObject



30
31
32
# File 'lib/wordify_becz.rb', line 30

def self.random_day
['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'].sample
end

.reversify(str) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/wordify_becz.rb', line 5

def self.reversify(str)
  reversed_string = ''
  (str.length-1).downto(0).each do |n|
    reversed_string << str[n]
  end 
  reversed_string
end

.spacify(str, spaces = 0) ⇒ Object



23
24
25
26
27
28
# File 'lib/wordify_becz.rb', line 23

def self.spacify(str, spaces = 0)
  new_string = str
  # using spaces variable to loop how many times
  spaces.times { new_string = new_string.split("").join(" ") }
  new_string
end