Class: CommandSuggestion

Inherits:
Object
  • Object
show all
Defined in:
lib/command/command_suggestion.rb

Constant Summary collapse

SHORT_ENOUGH =
3

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(wordlist) ⇒ CommandSuggestion

Returns a new instance of CommandSuggestion.



6
7
8
# File 'lib/command/command_suggestion.rb', line 6

def initialize(wordlist)
  @wordlist = wordlist
end

Instance Attribute Details

#wordlistObject

Returns the value of attribute wordlist.



2
3
4
# File 'lib/command/command_suggestion.rb', line 2

def wordlist
  @wordlist
end

Instance Method Details

#abbreviationObject



18
19
20
# File 'lib/command/command_suggestion.rb', line 18

def abbreviation
  wordlist.map{|w| CommandWord.suggested_letter(w) }.join.downcase
end

#to_sObject



10
11
12
13
14
15
16
# File 'lib/command/command_suggestion.rb', line 10

def to_s
  if exists?
    "'#{command}' => #{abbreviation} taken :("
  else
    "'#{command}' => " + "#{abbreviation}".green
  end
end