Class: OptParseBuilder::ArgumentBundle

Inherits:
Argument
  • Object
show all
Defined in:
lib/opt_parse_builder/argument_bundle.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods inherited from Argument

#apply_option, #banner_lines, #footer_lines, #key, #operand_notation, #optional, #required, #reset, #separator_lines, #shift_operand, #value, #value=

Constructor Details

#initializeArgumentBundle

Returns a new instance of ArgumentBundle.



4
5
6
# File 'lib/opt_parse_builder/argument_bundle.rb', line 4

def initialize
  @arguments = []
end

Instance Method Details

#<<(argument) ⇒ Object



8
9
10
# File 'lib/opt_parse_builder/argument_bundle.rb', line 8

def <<(argument)
  @arguments << argument
end

#simplifyObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/opt_parse_builder/argument_bundle.rb', line 18

def simplify
  case @arguments.count
  when 0
    NullArgument.new
  when 1
    @arguments.first
  else
    self
  end
end

#to_aObject



12
13
14
15
16
# File 'lib/opt_parse_builder/argument_bundle.rb', line 12

def to_a
  @arguments.reduce([]) do |a, arg|
    a + arg.to_a
  end
end