Class: DocoptNG::ParentPattern
- Defined in:
- lib/docopt_ng/parent_pattern.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
Instance Method Summary collapse
- #flat(*types) ⇒ Object
-
#initialize(*children) ⇒ ParentPattern
constructor
A new instance of ParentPattern.
- #inspect ⇒ Object
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.
7 8 9 |
# File 'lib/docopt_ng/parent_pattern.rb', line 7 def initialize(*children) @children = children end |
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
5 6 7 |
# File 'lib/docopt_ng/parent_pattern.rb', line 5 def children @children end |
Instance Method Details
#flat(*types) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/docopt_ng/parent_pattern.rb', line 16 def flat(*types) if types.include?(self.class) [self] else children.map { |c| c.flat(*types) }.flatten end end |
#inspect ⇒ Object
11 12 13 14 |
# File 'lib/docopt_ng/parent_pattern.rb', line 11 def inspect childstr = children.map(&:inspect) "#{self.class.name}(#{childstr.join(', ')})" end |