Class: GetoptLong::DSL

Inherits:
Object show all
Defined in:
lib/more/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.



62
63
64
65
# File 'lib/more/facets/getoptlong.rb', line 62

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

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



60
61
62
# File 'lib/more/facets/getoptlong.rb', line 60

def arguments
  @arguments
end

Instance Method Details

#flag(*opts) ⇒ Object



67
68
69
# File 'lib/more/facets/getoptlong.rb', line 67

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

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



76
77
78
# File 'lib/more/facets/getoptlong.rb', line 76

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

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



71
72
73
# File 'lib/more/facets/getoptlong.rb', line 71

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