Class: SyntaxTree::ERB::ErbContent
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::ERB::ErbContent
show all
- Defined in:
- lib/syntax_tree/erb/nodes.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Node
#format, #pretty_print, #skip?, #without_new_line
Constructor Details
#initialize(value:) ⇒ ErbContent
Returns a new instance of ErbContent.
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
|
# File 'lib/syntax_tree/erb/nodes.rb', line 467
def initialize(value:)
if value.is_a?(Array)
value =
value
.map do |token|
if token.is_a?(Token)
token.value
elsif token.is_a?(ErbYield)
ErbYield::PLACEHOLDER
else
token
end
end
.join
end
@value = SyntaxTree.parse(value.strip)
end
|
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
465
466
467
|
# File 'lib/syntax_tree/erb/nodes.rb', line 465
def value
@value
end
|
Instance Method Details
#accept(visitor) ⇒ Object
494
495
496
|
# File 'lib/syntax_tree/erb/nodes.rb', line 494
def accept(visitor)
visitor.visit_erb_content(self)
end
|
#blank? ⇒ Boolean
485
486
487
488
489
490
491
492
|
# File 'lib/syntax_tree/erb/nodes.rb', line 485
def blank?
value.nil? ||
value
.statements
.child_nodes
.reject { |node| node.is_a?(SyntaxTree::VoidStmt) }
.empty?
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
498
499
500
|
# File 'lib/syntax_tree/erb/nodes.rb', line 498
def child_nodes
[@value].compact
end
|
#deconstruct_keys(keys) ⇒ Object
504
505
506
|
# File 'lib/syntax_tree/erb/nodes.rb', line 504
def deconstruct_keys(keys)
{ value: value }
end
|