Class: RailsInteractive::CLI::Command
- Inherits:
-
Object
- Object
- RailsInteractive::CLI::Command
- Defined in:
- lib/cli/command.rb
Overview
Commands class for the interactive CLI module
Instance Method Summary collapse
- #all ⇒ Object
- #dependencies(identifier) ⇒ Object
- #find_by_identifier(identifier) ⇒ Object
-
#initialize ⇒ Command
constructor
A new instance of Command.
Constructor Details
#initialize ⇒ Command
Returns a new instance of Command.
9 10 11 |
# File 'lib/cli/command.rb', line 9 def initialize @commands = YAML.load_file("#{__dir__}/config/commands.yml").uniq end |
Instance Method Details
#all ⇒ Object
13 14 15 |
# File 'lib/cli/command.rb', line 13 def all @commands end |
#dependencies(identifier) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/cli/command.rb', line 21 def dependencies(identifier) identifier = identifier.is_a?(Array) ? identifier.join("") : identifier command ||= find_by_identifier(identifier) command["dependencies"] end |
#find_by_identifier(identifier) ⇒ Object
17 18 19 |
# File 'lib/cli/command.rb', line 17 def find_by_identifier(identifier) @commands.find { |command| command["identifier"] == identifier } end |