Class: SyntaxTree::ERB::ErbContent

Inherits:
Node
  • Object
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

Constructor Details

#initialize(value:) ⇒ ErbContent

Returns a new instance of ErbContent.



362
363
364
365
366
367
368
369
370
# File 'lib/syntax_tree/erb/nodes.rb', line 362

def initialize(value:)
  @unparsed_value = value
  begin
    @value = SyntaxTree.parse(value.strip)
  rescue SyntaxTree::Parser::ParseError
    # Removes leading and trailing whitespace
    @value = value&.lstrip&.rstrip
  end
end

Instance Attribute Details

#unparsed_valueObject (readonly)

Returns the value of attribute unparsed_value.



360
361
362
# File 'lib/syntax_tree/erb/nodes.rb', line 360

def unparsed_value
  @unparsed_value
end

#valueObject (readonly)

Returns the value of attribute value.



360
361
362
# File 'lib/syntax_tree/erb/nodes.rb', line 360

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



372
373
374
# File 'lib/syntax_tree/erb/nodes.rb', line 372

def accept(visitor)
  visitor.visit_erb_content(self)
end

#child_nodesObject Also known as: deconstruct



376
377
378
# File 'lib/syntax_tree/erb/nodes.rb', line 376

def child_nodes
  []
end

#deconstruct_keys(keys) ⇒ Object



382
383
384
# File 'lib/syntax_tree/erb/nodes.rb', line 382

def deconstruct_keys(keys)
  { value: value }
end