Class: Taipo::TypeElement::Children Private
- Inherits:
-
Array
- Object
- Array
- Taipo::TypeElement::Children
- Defined in:
- lib/taipo/type_element/children.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A set of Taipo::TypeElements representing the types of the children of a collection type
Instance Method Summary collapse
-
#initialize(children = nil) ⇒ Children
constructor
private
Initialize a new set of children.
-
#to_s ⇒ String
private
Return the String representation of this object.
Constructor Details
#initialize(children = nil) ⇒ Children
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The children
argument is an array of Taipo::TypeElements because the element returned by an enumerator for a collection can consist of multiple components (eg. in a Hash, where it consists of two elements).
Initialize a new set of children
23 24 25 |
# File 'lib/taipo/type_element/children.rb', line 23 def initialize(children = nil) children&.each { |c| self.push c } end |
Instance Method Details
#to_s ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return the String representation of this object
33 34 35 36 37 38 39 40 41 |
# File 'lib/taipo/type_element/children.rb', line 33 def to_s inner = self.reduce(nil) do |memo_e,component| el = component.reduce(nil) do |memo_c,c| (memo_c.nil?) ? c.to_s : memo_c + '|' + c.to_s end (memo_e.nil?) ? el : memo_e + ',' + el end '<' + inner + '>' end |