Class: Kerplutz::Flag
Instance Attribute Summary collapse
-
#arg_name ⇒ Object
Returns the value of attribute arg_name.
-
#arg_required ⇒ Object
Returns the value of attribute arg_required.
Attributes inherited from Option
Class Method Summary collapse
Instance Method Summary collapse
- #configure(parser, &blk) ⇒ Object
-
#initialize(name, desc, arg_name = nil) ⇒ Flag
constructor
A new instance of Flag.
- #option_sig ⇒ Object
Methods inherited from Option
#abbrev_sig, #display_name, #parser_args
Constructor Details
#initialize(name, desc, arg_name = nil) ⇒ Flag
Returns a new instance of Flag.
48 49 50 51 |
# File 'lib/kerplutz/options.rb', line 48 def initialize(name, desc, arg_name=nil) super(name, desc) @arg_name = arg_name end |
Instance Attribute Details
#arg_name ⇒ Object
Returns the value of attribute arg_name.
39 40 41 |
# File 'lib/kerplutz/options.rb', line 39 def arg_name @arg_name end |
#arg_required ⇒ Object
Returns the value of attribute arg_required.
39 40 41 |
# File 'lib/kerplutz/options.rb', line 39 def arg_required @arg_required end |
Class Method Details
.build(name, desc, opts) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/kerplutz/options.rb', line 41 def self.build(name, desc, opts) flag = super(name, desc, opts) flag.arg_name = opts[:required] || opts[:optional] flag.arg_required = opts.has_key?(:required) flag end |
Instance Method Details
#configure(parser, &blk) ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/kerplutz/options.rb', line 53 def configure(parser, &blk) parser.on(*parser_args) do |arg| if NilClass === arg blk.call(true) else blk.call(arg) end end end |
#option_sig ⇒ Object
63 64 65 |
# File 'lib/kerplutz/options.rb', line 63 def option_sig "#{super}#{formatted_arg_name}" end |