Class: Taipo::TypeElement::Children Private

Inherits:
Array
  • Object
show all
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

Since:

  • 1.4.0

Instance Method Summary collapse

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.

Note:

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

Parameters:

  • children (Array<Taipo::TypeElements>) (defaults to: nil)

    the components that make up the children of the collection

Since:

  • 1.4.0



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_sString

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

Returns:

  • (String)

    the representation as a String

Since:

  • 1.4.0



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