Class: Pigs

Inherits:
Object
  • Object
show all
Defined in:
app/pigs.rb

Overview

You know, pig stuff.

Class Method Summary collapse

Class Method Details

.generate_phraseObject



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'app/pigs.rb', line 109

def self.generate_phrase
  rand = rand(TOTAL_COMBOS)
  COMBOS.each_with_index do |combo, i|
    next unless rand < COMBO_SUM[i]

    used = []
    parts = []
    combo.each do |list|
      list -= used
      used << list.sample
      parts << used.last
    end
    return parts.join('-')
  end
end

.total_combosObject



105
106
107
# File 'app/pigs.rb', line 105

def self.total_combos
  TOTAL_COMBOS
end