Class: YARP::StringNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::StringNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
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"
^^^^ ^^^^
Instance Attribute Summary collapse
-
#closing_loc ⇒ Object
readonly
attr_reader closing_loc: Location?.
-
#content_loc ⇒ Object
readonly
attr_reader content_loc: Location.
-
#opening_loc ⇒ Object
readonly
attr_reader opening_loc: Location?.
-
#unescaped ⇒ Object
readonly
attr_reader unescaped: String.
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
-
#closing ⇒ Object
def closing: () -> String?.
-
#content ⇒ Object
def content: () -> String.
-
#copy(**params) ⇒ Object
def copy: (**params) -> StringNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(opening_loc, content_loc, closing_loc, unescaped, location) ⇒ StringNode
constructor
def initialize: (opening_loc: Location?, content_loc: Location, closing_loc: Location?, unescaped: String, location: Location) -> void.
-
#opening ⇒ Object
def opening: () -> String?.
Constructor Details
#initialize(opening_loc, content_loc, closing_loc, unescaped, location) ⇒ StringNode
def initialize: (opening_loc: Location?, content_loc: Location, closing_loc: Location?, unescaped: String, location: Location) -> void
7246 7247 7248 7249 7250 7251 7252 |
# File 'lib/yarp/node.rb', line 7246 def initialize(opening_loc, content_loc, closing_loc, unescaped, location) @opening_loc = opening_loc @content_loc = content_loc @closing_loc = closing_loc @unescaped = unescaped @location = location end |
Instance Attribute Details
#closing_loc ⇒ Object (readonly)
attr_reader closing_loc: Location?
7240 7241 7242 |
# File 'lib/yarp/node.rb', line 7240 def closing_loc @closing_loc end |
#content_loc ⇒ Object (readonly)
attr_reader content_loc: Location
7237 7238 7239 |
# File 'lib/yarp/node.rb', line 7237 def content_loc @content_loc end |
#opening_loc ⇒ Object (readonly)
attr_reader opening_loc: Location?
7234 7235 7236 |
# File 'lib/yarp/node.rb', line 7234 def opening_loc @opening_loc end |
#unescaped ⇒ Object (readonly)
attr_reader unescaped: String
7243 7244 7245 |
# File 'lib/yarp/node.rb', line 7243 def unescaped @unescaped end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
7255 7256 7257 |
# File 'lib/yarp/node.rb', line 7255 def accept(visitor) visitor.visit_string_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
7260 7261 7262 |
# File 'lib/yarp/node.rb', line 7260 def child_nodes [] end |
#closing ⇒ Object
def closing: () -> String?
7294 7295 7296 |
# File 'lib/yarp/node.rb', line 7294 def closing closing_loc&.slice end |
#content ⇒ Object
def content: () -> String
7289 7290 7291 |
# File 'lib/yarp/node.rb', line 7289 def content content_loc.slice end |
#copy(**params) ⇒ Object
def copy: (**params) -> StringNode
7265 7266 7267 7268 7269 7270 7271 7272 7273 |
# File 'lib/yarp/node.rb', line 7265 def copy(**params) StringNode.new( params.fetch(:opening_loc) { opening_loc }, params.fetch(:content_loc) { content_loc }, params.fetch(:closing_loc) { closing_loc }, params.fetch(:unescaped) { unescaped }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
7279 7280 7281 |
# File 'lib/yarp/node.rb', line 7279 def deconstruct_keys(keys) { opening_loc: opening_loc, content_loc: content_loc, closing_loc: closing_loc, unescaped: unescaped, location: location } end |
#opening ⇒ Object
def opening: () -> String?
7284 7285 7286 |
# File 'lib/yarp/node.rb', line 7284 def opening opening_loc&.slice end |