Class: SyntaxTree::TStringContent

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

Overview

TStringContent represents plain characters inside of an entity that accepts string content like a string, heredoc, command string, or regular expression.

"string"

In the example above, TStringContent represents the string token contained within the string.

Instance Attribute Summary collapse

Attributes inherited from Node

#location

Instance Method Summary collapse

Methods inherited from Node

#pretty_print, #to_json

Constructor Details

#initialize(value:, location:, comments: []) ⇒ TStringContent

Returns a new instance of TStringContent.



8103
8104
8105
8106
8107
# File 'lib/syntax_tree/node.rb', line 8103

def initialize(value:, location:, comments: [])
  @value = value
  @location = location
  @comments = comments
end

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



8101
8102
8103
# File 'lib/syntax_tree/node.rb', line 8101

def comments
  @comments
end

#valueObject (readonly)

String

the content of the string



8098
8099
8100
# File 'lib/syntax_tree/node.rb', line 8098

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



8113
8114
8115
# File 'lib/syntax_tree/node.rb', line 8113

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

#child_nodesObject Also known as: deconstruct



8117
8118
8119
# File 'lib/syntax_tree/node.rb', line 8117

def child_nodes
  []
end

#deconstruct_keys(keys) ⇒ Object



8123
8124
8125
# File 'lib/syntax_tree/node.rb', line 8123

def deconstruct_keys(keys)
  { value: value, location: location, comments: comments }
end

#format(q) ⇒ Object



8127
8128
8129
# File 'lib/syntax_tree/node.rb', line 8127

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

#match?(pattern) ⇒ Boolean

Returns:

  • (Boolean)


8109
8110
8111
# File 'lib/syntax_tree/node.rb', line 8109

def match?(pattern)
  value.match?(pattern)
end