Class: PUNK::Command
- Inherits:
-
Object
- Object
- PUNK::Command
- Defined in:
- lib/punk/framework/command.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#opts ⇒ Object
Returns the value of attribute opts.
Class Method Summary collapse
Instance Method Summary collapse
- #description(text) ⇒ Object
- #option(name:, description:, shortcut: nil, type: String) ⇒ Object
- #process ⇒ Object
- #shortcut(name) ⇒ Object
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
8 9 10 |
# File 'lib/punk/framework/command.rb', line 8 def args @args end |
#opts ⇒ Object
Returns the value of attribute opts.
8 9 10 |
# File 'lib/punk/framework/command.rb', line 8 def opts @opts end |
Class Method Details
.commander ⇒ Object
41 42 43 44 45 |
# File 'lib/punk/framework/command.rb', line 41 def self.commander PUNK.store.commands.each_value do |command| command.send(:_commander) end end |
.create(name, &block) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/punk/framework/command.rb', line 10 def self.create(name, &block) command = new command.send(:_init, name) PUNK.store.commands ||= {} PUNK.store.commands[name] = command command.instance_eval(&block) end |
.pry ⇒ Object
35 36 37 38 39 |
# File 'lib/punk/framework/command.rb', line 35 def self.pry PUNK.store.commands.each_value do |command| command.send(:_pry) end end |
.spec(scope) ⇒ Object
47 48 49 50 51 |
# File 'lib/punk/framework/command.rb', line 47 def self.spec(scope) PUNK.store.commands.each_value do |command| command.send(:_spec, scope) end end |
Instance Method Details
#description(text) ⇒ Object
22 23 24 |
# File 'lib/punk/framework/command.rb', line 22 def description(text) instance_variable_set(:@description, text) end |
#option(name:, description:, shortcut: nil, type: String) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/punk/framework/command.rb', line 26 def option(name:, description:, shortcut: nil, type: String) @options[name] = { name: name, description: description, shortcut: shortcut, type: type } end |
#process ⇒ Object
53 54 55 |
# File 'lib/punk/framework/command.rb', line 53 def process raise NotImplemented, "command must provide process method" end |
#shortcut(name) ⇒ Object
18 19 20 |
# File 'lib/punk/framework/command.rb', line 18 def shortcut(name) instance_variable_set(:@shortcut, name) end |