Module: Lorca::Phrases::LorcaPlugin

Defined in:
lib/lorca/expansions/phrases.rb

Instance Method Summary collapse

Instance Method Details

#phrase(words: nil) ⇒ Object

The phrase written given a number of words. Defaults to Phrases::MIN_WORDS



44
45
46
47
48
49
50
51
# File 'lib/lorca/expansions/phrases.rb', line 44

def phrase words: nil
  conf = settings[:phrases]
  words = words ? words : conf[:min_words]
  words = validate_counter words, range: conf[:min_words]..conf[:max_words]
  phrase_ids = []
  words.times { phrase_ids.push(roll_word_id dice: conf[:dice_to_toss]) }
  phrase_ids.map(&method(:word)).join " "
end