Class: SyntaxTree::EmbDoc

Inherits:
Node
  • Object
show all
Defined in:
lib/syntax_tree/node.rb

Overview

EmbDoc represents a multi-line comment.

=begin
first line
second line
=end

Instance Attribute Summary collapse

Attributes inherited from Node

#location

Instance Method Summary collapse

Methods inherited from Node

#construct_keys, #pretty_print, #to_json

Constructor Details

#initialize(value:, location:) ⇒ EmbDoc



4886
4887
4888
4889
# File 'lib/syntax_tree/node.rb', line 4886

def initialize(value:, location:)
  @value = value
  @location = location
end

Instance Attribute Details

#valueObject (readonly)

String

the contents of the comment



4884
4885
4886
# File 'lib/syntax_tree/node.rb', line 4884

def value
  @value
end

Instance Method Details

#===(other) ⇒ Object



4929
4930
4931
# File 'lib/syntax_tree/node.rb', line 4929

def ===(other)
  other.is_a?(EmbDoc) && value === other.value
end

#accept(visitor) ⇒ Object



4903
4904
4905
# File 'lib/syntax_tree/node.rb', line 4903

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

#child_nodesObject Also known as: deconstruct



4907
4908
4909
# File 'lib/syntax_tree/node.rb', line 4907

def child_nodes
  []
end

#commentsObject



4899
4900
4901
# File 'lib/syntax_tree/node.rb', line 4899

def comments
  []
end

#copy(value: nil, location: nil) ⇒ Object



4911
4912
4913
4914
4915
4916
# File 'lib/syntax_tree/node.rb', line 4911

def copy(value: nil, location: nil)
  EmbDoc.new(
    value: value || self.value,
    location: location || self.location
  )
end

#deconstruct_keys(_keys) ⇒ Object



4920
4921
4922
# File 'lib/syntax_tree/node.rb', line 4920

def deconstruct_keys(_keys)
  { value: value, location: location }
end

#format(q) ⇒ Object



4924
4925
4926
4927
# File 'lib/syntax_tree/node.rb', line 4924

def format(q)
  q.trim
  q.text(value)
end

#ignore?Boolean



4895
4896
4897
# File 'lib/syntax_tree/node.rb', line 4895

def ignore?
  false
end

#inline?Boolean



4891
4892
4893
# File 'lib/syntax_tree/node.rb', line 4891

def inline?
  false
end