Class: Carrasco::Command
- Inherits:
-
Object
- Object
- Carrasco::Command
- Defined in:
- lib/carrasco/command.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
(also: #to_s)
readonly
Returns the value of attribute command.
-
#command_name ⇒ Object
readonly
Returns the value of attribute command_name.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#help ⇒ Object
readonly
Returns the value of attribute help.
Instance Method Summary collapse
-
#initialize(command_name, options = {}) ⇒ Command
constructor
A new instance of Command.
- #inject_into_class(klass) ⇒ Object
Constructor Details
#initialize(command_name, options = {}) ⇒ Command
Returns a new instance of Command.
8 9 10 11 12 13 14 |
# File 'lib/carrasco/command.rb', line 8 def initialize(command_name, = {}) = Thor::CoreExt::HashWithIndifferentAccess.new() @command_name = command_name @command = [:command] || command_name @help = [:help] || command_name @description = [:description] || "description not given" end |
Instance Attribute Details
#command ⇒ Object (readonly) Also known as: to_s
Returns the value of attribute command.
5 6 7 |
# File 'lib/carrasco/command.rb', line 5 def command @command end |
#command_name ⇒ Object (readonly)
Returns the value of attribute command_name.
5 6 7 |
# File 'lib/carrasco/command.rb', line 5 def command_name @command_name end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
5 6 7 |
# File 'lib/carrasco/command.rb', line 5 def description @description end |
#help ⇒ Object (readonly)
Returns the value of attribute help.
5 6 7 |
# File 'lib/carrasco/command.rb', line 5 def help @help end |
Instance Method Details
#inject_into_class(klass) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/carrasco/command.rb', line 16 def inject_into_class(klass) command = self klass.desc(help, description) klass.class_eval do define_method(command.command_name) do execute_command(command) end end end |