Module: DeepCover::Node::Mixin::HasChild

Defined in:
lib/deep_cover/node/mixin/has_child.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

CHILDREN =
{}.freeze
CHILDREN_TYPES =
{}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



6
7
8
# File 'lib/deep_cover/node/mixin/has_child.rb', line 6

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#child_index_to_name(index) ⇒ Object



24
25
26
# File 'lib/deep_cover/node/mixin/has_child.rb', line 24

def child_index_to_name(index)
  self.class.child_index_to_name(index, children.size)
end

#initializeObject



12
13
14
15
# File 'lib/deep_cover/node/mixin/has_child.rb', line 12

def initialize(*)
  super
  self.validate_children_types(children)
end

#validate_children_types(nodes) ⇒ Object



17
18
19
20
21
22
# File 'lib/deep_cover/node/mixin/has_child.rb', line 17

def validate_children_types(nodes)
  mismatches = self.class.check_children_types(nodes)
  unless mismatches.empty?
    raise TypeError, "Invalid children types for #{self.class}(type: #{self.type}): #{mismatches}"
  end
end