Class: GetoptLong::DSL

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

Overview

DSL-mode parser.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ DSL

Returns a new instance of DSL.



31
32
33
34
# File 'lib/standard/facets/getoptlong.rb', line 31

def initialize(&block)
  @arguments = []
  instance_eval(&block)
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



29
30
31
# File 'lib/standard/facets/getoptlong.rb', line 29

def arguments
  @arguments
end

Instance Method Details

#flag(*opts) ⇒ Object



37
38
39
# File 'lib/standard/facets/getoptlong.rb', line 37

def flag(*opts)
  @arguments << (opts << GetoptLong::NO_ARGUMENT)
end

#optional(*opts) ⇒ Object Also known as: opts



50
51
52
# File 'lib/standard/facets/getoptlong.rb', line 50

def optional(*opts)
  @arguments << (opts << GetoptLong::OPTIONAL_ARGUMENT)
end

#required(*opts) ⇒ Object Also known as: reqs



42
43
44
# File 'lib/standard/facets/getoptlong.rb', line 42

def required(*opts)
  @arguments << (opts <<  GetoptLong::REQUIRED_ARGUMENT)
end