Class: Optio::Switch

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

Instance Method Summary collapse

Constructor Details

#initialize(name, opts) ⇒ Switch

TODO mandatory switch



5
6
7
8
# File 'lib/optio/switch.rb', line 5

def initialize(name, opts)
  @name = name
  @opts = opts
end

Instance Method Details

#rb_parser_argsObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/optio/switch.rb', line 10

def rb_parser_args
  args = ["--#{@name} #{@name.upcase}"]
  if @opts[:short]
    args.unshift("-#{@opts[:short]} #{@name.upcase}")
  end
  [:type, :desc].each do |key|
    if @opts[key]
      args << @opts[key]
    end
  end
  args
end