Represents a string literal, a string contained within a ‘%w` list, or plain string content within an interpolated string.

"foo"
^^^^^

%w[foo]
   ^^^

"foo #{bar} baz"
 ^^^^      ^^^^
Attributes
Read

attr_reader unescaped: String

Class Methods

Initialize a new StringNode node.

Return a symbol representation of this node type. See ‘Node::type`.

Instance Methods

Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.

def accept: (Visitor visitor) -> void

def child_nodes: () -> Array[nil | Node]

def closing: () -> String?

attr_reader closing_loc: Location?

def comment_targets: () -> Array[Node | Location]

def content: () -> String

attr_reader content_loc: Location

def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location?, ?content_loc: Location, ?closing_loc: Location?, ?unescaped: String) -> StringNode

An alias for child_nodes

def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, opening_loc: Location?, content_loc: Location, closing_loc: Location?, unescaped: String }

def forced_binary_encoding?: () -> bool

def forced_utf8_encoding?: () -> bool

def frozen?: () -> bool

def inspect -> String

def mutable?: () -> bool

def opening: () -> String?

attr_reader opening_loc: Location?

Save the closing_loc location using the given saved source so that it can be retrieved later.

Save the content_loc location using the given saved source so that it can be retrieved later.

Save the opening_loc location using the given saved source so that it can be retrieved later.

Occasionally it’s helpful to treat a string as if it were interpolated so that there’s a consistent interface for working with strings.

Return a symbol representation of this node type. See ‘Node#type`.