class Optio::Switch

Public Class Methods

new(name, opts) click to toggle source

TODO mandatory switch

# File lib/optio/switch.rb, line 5
def initialize(name, opts)
  @name = name
  @opts = opts
end

Public Instance Methods

rb_parser_args() click to toggle source
# 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