Class: LibRubyParser::Nodes::Str

Inherits:
LibRubyParser::Node show all
Defined in:
lib/lib-ruby-parser/nodes.rb

Overview

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

Instance Attribute Summary collapse

Instance Attribute Details

#begin_lLoc? (readonly)

Location of the string begin

"foo"
~

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

Returns:



3879
3880
3881
# File 'lib/lib-ruby-parser/nodes.rb', line 3879

def begin_l
  @begin_l
end

#end_lLoc? (readonly)

Location of the string begin

"foo"
    ~

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

Returns:



3890
3891
3892
# File 'lib/lib-ruby-parser/nodes.rb', line 3890

def end_l
  @end_l
end

#expression_lLoc (readonly)

Location of the full expression

"foo"
~~~~~

Returns:



3899
3900
3901
# File 'lib/lib-ruby-parser/nodes.rb', line 3899

def expression_l
  @expression_l
end

#valueString (readonly)

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.

Returns:

  • (String)


3868
3869
3870
# File 'lib/lib-ruby-parser/nodes.rb', line 3868

def value
  @value
end