Class: Kerplutz::Action

Inherits:
Option
  • Object
show all
Defined in:
lib/kerplutz/options.rb

Instance Attribute Summary collapse

Attributes inherited from Option

#abbrev, #desc, #name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Option

#abbrev_sig, #display_name, #option_sig, #parser_args

Constructor Details

#initialize(name, desc, &action) ⇒ Action

Returns a new instance of Action.



99
100
101
102
# File 'lib/kerplutz/options.rb', line 99

def initialize(name, desc, &action)
  super(name, desc)
  @action = action
end

Instance Attribute Details

#actionObject

Returns the value of attribute action.



91
92
93
# File 'lib/kerplutz/options.rb', line 91

def action
  @action
end

#continue_after_execObject

Returns the value of attribute continue_after_exec.



91
92
93
# File 'lib/kerplutz/options.rb', line 91

def continue_after_exec
  @continue_after_exec
end

Class Method Details

.build(name, desc, opts, &action) ⇒ Object



93
94
95
96
97
# File 'lib/kerplutz/options.rb', line 93

def self.build(name, desc, opts, &action)
  new_action = super(name, desc, opts)
  new_action.action = action
  new_action
end

Instance Method Details

#configure(parser, &blk) ⇒ Object



104
105
106
107
108
109
# File 'lib/kerplutz/options.rb', line 104

def configure(parser, &blk)
  parser.on(*parser_args) do
    action.call
    exit unless continue_after_exec
  end
end