Class: GetoptLong

Inherits:
Object show all
Defined in:
lib/more/facets/getoptlong.rb

Overview

GetoptLong

Ruby’s standard GetoptLong class with an added DSL.

opts = GetoptLong.new do
  reqs '--expect', '-x'
  flag '--help', '-h'
end

opts.each { |opt, arg|
  ...
}

Defined Under Namespace

Classes: DSL

Instance Method Summary collapse

Constructor Details

#initialize(*arguments, &block) ⇒ GetoptLong



49
50
51
52
53
54
55
# File 'lib/more/facets/getoptlong.rb', line 49

def initialize(*arguments, &block)
  if block_given?
    raise ArgumentError unless arguments.empty?
    arguments = DSL.new(&block).arguments
  end
  init(*arguments)
end

Instance Method Details

#initObject



47
# File 'lib/more/facets/getoptlong.rb', line 47

alias :init :initialize