Class: FakerBot::Commands::Search
- Inherits:
-
Object
- Object
- FakerBot::Commands::Search
- Defined in:
- lib/fakerbot/commands/search.rb
Instance Method Summary collapse
- #execute(input) ⇒ Object
-
#initialize(options) ⇒ Search
constructor
A new instance of Search.
- #not_found ⇒ Object
- #tree(input) ⇒ Object
Constructor Details
#initialize(options) ⇒ Search
Returns a new instance of Search.
10 11 12 |
# File 'lib/fakerbot/commands/search.rb', line 10 def initialize() @options = end |
Instance Method Details
#execute(input) ⇒ Object
14 15 16 17 |
# File 'lib/fakerbot/commands/search.rb', line 14 def execute(input) result = FakerBot::Bot.find(input) puts result.empty? ? not_found : tree(result).render end |
#not_found ⇒ Object
29 30 31 |
# File 'lib/fakerbot/commands/search.rb', line 29 def not_found "\n ☹️ Sorry, we couldn't find a match\n" end |
#tree(input) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/fakerbot/commands/search.rb', line 19 def tree(input) TTY::Tree.new do input.each do |faker, methods| node Pastel.new.green(faker.to_s) do methods.each { |m| leaf Pastel.new.cyan(m.to_s) } end end end end |