module WordifyBecz

all code for Gem goes in this file any time you add more code to your gem, must run in terminal: gem build wordify_becz.gemspec

Constants

VERSION
need to update version EACH time you push your gem

major.minor.patch

Public Class Methods

casify(str) click to toggle source
# 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_day() click to toggle source
# File lib/wordify_becz.rb, line 30
def self.random_day
  ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'].sample
  end
reversify(str) click to toggle source
# 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) click to toggle source
# 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