Class: Gemwarrior::WordList

Inherits:
Object
  • Object
show all
Defined in:
lib/gemwarrior/misc/wordlist.rb

Constant Summary collapse

STATIC_NOUN_VALUES =
["abutments", "asterisms", "bains", "blebs", "blowholes", "chapes", "civility", "crocuses", "dancers", "deniers", "diastoles", "dinges", "dualism", "ebullitions", "extremities", "fingering", "gabardines", "gullets", "knops", "nooks", "payments", "phaetons", "scalawags", "snickers", "specters", "splats", "squiggles", "thalamuses", "wallets", "xylophones"]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, limit = 10) ⇒ WordList

Returns a new instance of WordList.



13
14
15
16
17
18
# File 'lib/gemwarrior/misc/wordlist.rb', line 13

def initialize(type, limit = 10)
  self.type = type
  self.limit = limit
  self.words = populate_words(type, limit)
  self.error = nil
end

Instance Attribute Details

#errorObject

Returns the value of attribute error.



11
12
13
# File 'lib/gemwarrior/misc/wordlist.rb', line 11

def error
  @error
end

#limitObject

Returns the value of attribute limit.



11
12
13
# File 'lib/gemwarrior/misc/wordlist.rb', line 11

def limit
  @limit
end

#typeObject

Returns the value of attribute type.



11
12
13
# File 'lib/gemwarrior/misc/wordlist.rb', line 11

def type
  @type
end

#wordsObject

Returns the value of attribute words.



11
12
13
# File 'lib/gemwarrior/misc/wordlist.rb', line 11

def words
  @words
end

Instance Method Details

#get_random_valueObject



20
21
22
23
24
25
26
27
28
# File 'lib/gemwarrior/misc/wordlist.rb', line 20

def get_random_value
  random_value = words[rand(0..limit)]

  if random_value.nil?
    get_random_value
  else
    return random_value
  end
end

#list_wordsObject



30
31
32
# File 'lib/gemwarrior/misc/wordlist.rb', line 30

def list_words
  words.join(',')
end