lib-ruby-parser (C++ bindings)  4.0.1+ruby-3.1.1
C++ bindings for lib-ruby-parser library
lib_ruby_parser::Str Class Reference

Represents a plain non-interpolated string literal (e.g. "foo") More...

#include <nodes.hpp>

Public Attributes

Bytes value
 
MaybeLoc begin_l
 
MaybeLoc end_l
 
Loc expression_l
 

Detailed Description

Represents a plain non-interpolated string literal (e.g. "foo")

Member Data Documentation

◆ begin_l

MaybeLoc lib_ruby_parser::Str::begin_l

Location of the string begin

"foo"
^

None if string literal is a part of the words array (like w[foo bar baz])

◆ end_l

MaybeLoc lib_ruby_parser::Str::end_l

Location of the string begin

"foo"
^

None if string literal is a part of the words array (like w[foo bar baz])

◆ expression_l

Loc lib_ruby_parser::Str::expression_l

Location of the full expression

"foo"
^^^^^

◆ value

Bytes lib_ruby_parser::Str::value

Value of the string literal

Note that it's a StringValue, not a String. The reason is that you can get UTF-8 incompatible strings from a valid UTF-8 source using escape sequences like "\xFF"

These "\", "x", "F", "F" chars are valid separately, but together they construct a char with code = 255 that is invalid for UTF-8.

You can use to_string_lossy or to_string methods to get a raw string value.


The documentation for this class was generated from the following file: