class Madlibs::Madlib
Attributes
dictionary[R]
template[RW]
Public Class Methods
new(template = '', dictionary_hash = {})
click to toggle source
# File lib/madlibs/madlib.rb, line 10 def initialize template = '', dictionary_hash = {} self.template = template self.dictionary = dictionary_hash end
Public Instance Methods
dictionary=(hash)
click to toggle source
# File lib/madlibs/madlib.rb, line 15 def dictionary=(hash) @dictionary = Dictionary.new hash end
generate()
click to toggle source
# File lib/madlibs/madlib.rb, line 19 def generate @dictionary.reload Template.process_word_lists( Template.process_optionals( Template.keys(@template).reduce(@template) do |temp, key| Template.process_key temp, key, @dictionary.retrieve(key.pluralize) end ) ) end