Class: SyntaxTree::XString

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

Overview

XString represents the contents of an XStringLiteral.

`ls`

Instance Attribute Summary collapse

Attributes inherited from Node

#location

Instance Method Summary collapse

Methods inherited from Node

#construct_keys, #format, #pretty_print, #to_json

Constructor Details

#initialize(parts:, location:) ⇒ XString

Returns a new instance of XString.



12006
12007
12008
12009
# File 'lib/syntax_tree/node.rb', line 12006

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

Instance Attribute Details

#partsObject (readonly)

Array[ StringEmbExpr | StringDVar | TStringContent ]

the parts of the

xstring



12004
12005
12006
# File 'lib/syntax_tree/node.rb', line 12004

def parts
  @parts
end

Instance Method Details

#===(other) ⇒ Object



12032
12033
12034
# File 'lib/syntax_tree/node.rb', line 12032

def ===(other)
  other.is_a?(XString) && ArrayMatch.call(parts, other.parts)
end

#accept(visitor) ⇒ Object



12011
12012
12013
# File 'lib/syntax_tree/node.rb', line 12011

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

#child_nodesObject Also known as: deconstruct



12015
12016
12017
# File 'lib/syntax_tree/node.rb', line 12015

def child_nodes
  parts
end

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



12019
12020
12021
12022
12023
12024
# File 'lib/syntax_tree/node.rb', line 12019

def copy(parts: nil, location: nil)
  XString.new(
    parts: parts || self.parts,
    location: location || self.location
  )
end

#deconstruct_keys(_keys) ⇒ Object



12028
12029
12030
# File 'lib/syntax_tree/node.rb', line 12028

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