Module: Steep::AST::Types::Helper::ChildrenLevel

Included in:
Intersection, Name::Applying, Proc, Record, Tuple, Union
Defined in:
lib/steep/ast/types/helper.rb

Instance Method Summary collapse

Instance Method Details

#level_of_children(children) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/steep/ast/types/helper.rb', line 6

def level_of_children(children)
  levels = children.map(&:level)
  children.map(&:level).sort {|a, b| (b.size <=> a.size) || 0 }.inject() do |a, b|
    a.zip(b).map do |x, y|
      if x && y
        x + y
      else
        x || y || raise
      end
    end
  end || []
end