Class: RailsInteractive::CLI::Command

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

Overview

Commands class for the interactive CLI module

Instance Method Summary collapse

Constructor Details

#initializeCommand

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

#allObject



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