Class: Bade::MixinCallNode

Inherits:
MixinCommonNode show all
Defined in:
lib/bade/node/mixin_node.rb

Instance Attribute Summary collapse

Attributes inherited from MixinCommonNode

#params

Attributes inherited from Node

#childrens, #data, #escaped, #lineno, #parent, #type

Instance Method Summary collapse

Methods inherited from Node

create, register_type, registered_types

Constructor Details

#initialize(*args) ⇒ MixinCallNode

Returns a new instance of MixinCallNode.



38
39
40
41
42
# File 'lib/bade/node/mixin_node.rb', line 38

def initialize(*args)
  super

  @blocks = []
end

Instance Attribute Details

#blocksObject (readonly)

Returns the value of attribute blocks.



34
35
36
# File 'lib/bade/node/mixin_node.rb', line 34

def blocks
  @blocks
end

#default_blockObject (readonly)

Returns the value of attribute default_block.



36
37
38
# File 'lib/bade/node/mixin_node.rb', line 36

def default_block
  @default_block
end

Instance Method Details

#<<(node) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/bade/node/mixin_node.rb', line 48

def << (node)
  if allowed_parameter_types.include?(node.type)
    node.parent = self
    @params << node
  elsif node.type == :mixin_block
    node.parent = self
    @blocks << node
  else
    if @default_block.nil?
      if node.type == :newline
        # skip newlines at start
        return self
      end

      @default_block = Node.create(:mixin_block, self)
    end

    @default_block << node
  end
end

#allowed_parameter_typesObject



44
45
46
# File 'lib/bade/node/mixin_node.rb', line 44

def allowed_parameter_types
  [:mixin_param, :mixin_key_param]
end