Class: Twig::Node::Expression::Binary::Base

Inherits:
Twig::Node::Expression::Base show all
Defined in:
lib/twig/node/expression/binary/base.rb

Instance Attribute Summary

Attributes inherited from Base

#attributes, #lineno, #nodes, #source_context, #tag

Instance Method Summary collapse

Methods inherited from Twig::Node::Expression::Base

#explicit_parentheses?, #set_explicit_parentheses

Methods inherited from Base

#empty?, #length, #template_name, #to_s

Constructor Details

#initialize(left, right, lineno) ⇒ Base

Returns a new instance of Base.



8
9
10
# File 'lib/twig/node/expression/binary/base.rb', line 8

def initialize(left, right, lineno)
  super({ left:, right: }, {}, lineno)
end

Instance Method Details

#compile(compiler) ⇒ Object

Parameters:



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/twig/node/expression/binary/base.rb', line 13

def compile(compiler)
  compiler.
    raw('(').
    subcompile(nodes[:left]).
    raw(' ')

  operator(compiler)

  compiler.
    raw(' ').
    subcompile(nodes[:right]).
    raw(')')
end

#operator(compiler) ⇒ Object

Parameters:



28
29
30
# File 'lib/twig/node/expression/binary/base.rb', line 28

def operator(compiler)
  raise 'operator is not implemented'
end