Class: CliSwitch::Option

Inherits:
Object
  • Object
show all
Defined in:
lib/cliswitch.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_optionalObject

Returns the value of attribute arg_optional.



18
19
20
# File 'lib/cliswitch.rb', line 18

def arg_optional
  @arg_optional
end

#arg_requiredObject

Returns the value of attribute arg_required.



18
19
20
# File 'lib/cliswitch.rb', line 18

def arg_required
  @arg_required
end

#longObject

Returns the value of attribute long.



18
19
20
# File 'lib/cliswitch.rb', line 18

def long
  @long
end

#nameObject

Returns the value of attribute name.



18
19
20
# File 'lib/cliswitch.rb', line 18

def name
  @name
end

#next_argObject

Returns the value of attribute next_arg.



18
19
20
# File 'lib/cliswitch.rb', line 18

def next_arg
  @next_arg
end

#self_requiredObject

Returns the value of attribute self_required.



18
19
20
# File 'lib/cliswitch.rb', line 18

def self_required
  @self_required
end

#shortObject

Returns the value of attribute short.



18
19
20
# File 'lib/cliswitch.rb', line 18

def short
  @short
end