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

Included in:
Intersection, Name::Applying, 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
# File 'lib/steep/ast/types/helper.rb', line 6

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