Class: Docopt::ParentPattern
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.
180 181 182 |
# File 'lib/docopt.rb', line 180 def initialize(*children) @children = children end |
Instance Attribute Details
#children ⇒ Object
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 |
#inspect ⇒ Object
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 |