Module: DictClient::Formattable

Included in:
KeyValueResponse, WordMatch
Defined in:
lib/dict_client/responses.rb

Instance Method Summary collapse

Instance Method Details

#longest(list) ⇒ Object



36
37
38
# File 'lib/dict_client/responses.rb', line 36

def longest list
  list.max{|a,b| a.length <=> b.length }.length
end


40
41
42
43
44
# File 'lib/dict_client/responses.rb', line 40

def print_formatted list, max_key, max_value
  list.to_a.map do |k, v|
    sprintf "%#{max_key}s  %-#{max_value}s", k, v
  end.join("\n")
end