Class: Docopt::ParentPattern

Inherits:
Pattern
  • Object
show all
Defined in:
lib/docopt.rb

Direct Known Subclasses

Either, OneOrMore, Optional, Required

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Pattern

#==, #dump, #either, #fix, #fix_identities, #fix_repeating_arguments, #to_str

Constructor Details

#initialize(*children) ⇒ ParentPattern

Returns a new instance of ParentPattern.



180
181
182
# File 'lib/docopt.rb', line 180

def initialize(*children)
  @children = children
end

Instance Attribute Details

#childrenObject

Returns the value of attribute children.



178
179
180
# File 'lib/docopt.rb', line 178

def children
  @children
end

Instance Method Details

#flat(*types) ⇒ Object



189
190
191
192
193
194
195
# File 'lib/docopt.rb', line 189

def flat(*types)
  if types.include?(self.class)
    [self]
  else
    self.children.map { |c| c.flat(*types) }.flatten
  end
end

#inspectObject



184
185
186
187
# File 'lib/docopt.rb', line 184

def inspect
  childstr = self.children.map { |a| a.inspect }
  return "#{self.class.name}(#{childstr.join(", ")})"
end