Class: CliSwitch::Option
- Inherits:
-
Object
- Object
- CliSwitch::Option
- Defined in:
- lib/cliswitch.rb
Instance Attribute Summary collapse
-
#arg_optional ⇒ Object
Returns the value of attribute arg_optional.
-
#arg_required ⇒ Object
Returns the value of attribute arg_required.
-
#long ⇒ Object
Returns the value of attribute long.
-
#name ⇒ Object
Returns the value of attribute name.
-
#next_arg ⇒ Object
Returns the value of attribute next_arg.
-
#self_required ⇒ Object
Returns the value of attribute self_required.
-
#short ⇒ Object
Returns the value of attribute short.
Instance Method Summary collapse
-
#initialize(name:, short: nil, long: nil, self_required: false, arg_required: 'required', next_arg: nil) ⇒ Option
constructor
A new instance of Option.
Constructor Details
#initialize(name:, short: nil, long: nil, self_required: false, arg_required: 'required', next_arg: nil) ⇒ Option
Returns a new instance of Option.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/cliswitch.rb', line 26 def initialize(name:, short: nil, long: nil, self_required: false, # mandatory arg_required: 'required', next_arg: nil) if long.nil? and short.nil? puts "CliSwitch: Error! Must provide a short or long switch" return end case arg_required when 'required', 'optional', 'noarg' # do nothing else puts "CliSwitch: Error! arg_required must be ['required', 'optional', 'noarg'] " return end @name = name @short = short @long = long @self_required = self_required @arg_required = arg_required @next_arg = next_arg end |
Instance Attribute Details
#arg_optional ⇒ Object
Returns the value of attribute arg_optional.
18 19 20 |
# File 'lib/cliswitch.rb', line 18 def arg_optional @arg_optional end |
#arg_required ⇒ Object
Returns the value of attribute arg_required.
18 19 20 |
# File 'lib/cliswitch.rb', line 18 def arg_required @arg_required end |
#long ⇒ Object
Returns the value of attribute long.
18 19 20 |
# File 'lib/cliswitch.rb', line 18 def long @long end |
#name ⇒ Object
Returns the value of attribute name.
18 19 20 |
# File 'lib/cliswitch.rb', line 18 def name @name end |
#next_arg ⇒ Object
Returns the value of attribute next_arg.
18 19 20 |
# File 'lib/cliswitch.rb', line 18 def next_arg @next_arg end |
#self_required ⇒ Object
Returns the value of attribute self_required.
18 19 20 |
# File 'lib/cliswitch.rb', line 18 def self_required @self_required end |
#short ⇒ Object
Returns the value of attribute short.
18 19 20 |
# File 'lib/cliswitch.rb', line 18 def short @short end |