Class: Twig::Node::Expression::Unary::Base
- Defined in:
- lib/twig/node/expression/unary/base.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Base
#attributes, #lineno, #nodes, #source_context, #tag
Instance Method Summary collapse
- #compile(compiler) ⇒ Object
-
#initialize(node, lineno) ⇒ Base
constructor
A new instance of Base.
- #operator(compiler) ⇒ Object
Methods inherited from Base
#explicit_parentheses?, #set_explicit_parentheses
Methods inherited from Base
#empty?, #length, #template_name, #to_s
Constructor Details
#initialize(node, lineno) ⇒ Base
Returns a new instance of Base.
10 11 12 |
# File 'lib/twig/node/expression/unary/base.rb', line 10 def initialize(node, lineno) super({ node: }, { with_parenthesis: false }, lineno) end |
Instance Method Details
#compile(compiler) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/twig/node/expression/unary/base.rb', line 14 def compile(compiler) if explicit_parentheses? compiler.raw('(') else compiler.raw(' ') end operator(compiler) compiler.subcompile(nodes[:node]) if explicit_parentheses? compiler.raw(')') end end |
#operator(compiler) ⇒ Object
30 31 32 |
# File 'lib/twig/node/expression/unary/base.rb', line 30 def operator(compiler) raise 'operator is not implemented' end |