Method: Shhh::App::Commands::ShowLanguageExamples#example

Defined in:
lib/shhh/app/commands/show_language_examples.rb

#example(comment: nil, command: nil, echo: nil, result: nil) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/shhh/app/commands/show_language_examples.rb', line 57

def example(comment: nil, command: nil, echo: nil, result: nil)
  @dict   ||= ::Shhh::App::NLP::Constants::DICTIONARY.to_a.flatten!
  _command = command.split(' ').map do |w|
    _w = w.to_sym
    if w == 'shhh'
      w.italic.yellow
    elsif ::Shhh::App::NLP::Constants::STRIPPED.include?(_w)
      w.italic.red
    elsif @dict.include?(_w)
      w.blue
    else
      w
    end
  end.join(' ') if command
  out     = []
  out << "# #{comment}".white.dark.italic if comment
  out << "#{_command}" if command
  out << "#{echo}" if echo
  out << "#{result}" if result
  out << (' '*80).dark
end