class Beemovie::Barry
Public Class Methods
paragraph(num)
click to toggle source
# File lib/beemovie.rb, line 32 def self.paragraph(num) # Replaces all special characters with nothing except periods, question marks and commas script2 = $script.gsub(/[^a-zA-Z'.?, ]/, "") # Splits the Bee Movie Script into an array seperated by a period period = script2.split(".") # Splits the Bee Movie Script into an array seperated by a question question = script2.split("?") # Filters out every array object that is empty array1 = period.reject {|str| str == str.empty?} # Filters out every array object that is empty array2 = question.reject {|str| str == str.empty?} # Filters out every array object that only contains a period $array1 = array1.reject {|str| str == "."} # Filters out every array object that only contains a peroid $array2 = array2.reject {|str| str == "."} while num > 0 # An array with numbers of sentences to be generated numbersentence = [3,4,5] # Picks a random number from the numbersentence array $sentencenumber = numbersentence.sample # another while loop while $sentencenumber > 0 # an array with the data to randomly pick between a peroid sentence or a question sentence arrayPicker = ["period", "question"] # picks a random sentence type pickArray = arrayPicker.sample # checks if pickArray = period and if it doesn't, then it automatically assumes that it's a question if pickArray == "period" $pog = $pog + Beemovie::Paragraph.multiplySentences(1, $array1, pickArray) + " " else $pog = $pog + Beemovie::Paragraph.multiplySentences(1, $array2, pickArray) + " " end # subtracts 1 from the sentencenumber var $sentencenumber = $sentencenumber - 1 end # subtracts 1 from the num var num = num - 1 end return $pog end
script()
click to toggle source
# File lib/beemovie.rb, line 20 def self.script # Prints the Bee Movie script $script end
sentence(num)
click to toggle source
# File lib/beemovie.rb, line 10 def self.sentence(num) # Splits the Bee Movie Script into an array seperated by a period $barry = $script.split(".") # Filters out every array object that only contains a period $barryarr = $barry.reject {|str| str == "."} # Filters out every array object that is empty $barryarr2 = $barryarr.reject {|c| c.empty?} # Returns a sentence from the Bee Movie return Beemovie::Sentence.multiplySentences(num, $barryarr2) end
word(num)
click to toggle source
# File lib/beemovie.rb, line 24 def self.word(num) # Splits all special characters, I could do this better but this words. script2 = $script.gsub(".", "").gsub("?", "").gsub("-", "").gsub("!", "").gsub("?", "").gsub(",", "") # Splits the Bee Movie Script into an array seperated by a space. $barry = script2.split(" ") # Returns a word from the Bee Movie return Beemovie::Word.multiplySentences(num, $barry) end