123456789_123456789_123456789_123456789_123456789_

Class: Prism::StringNode

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Node
Instance Chain:
self, Node
Inherits: Prism::Node
Defined in: lib/prism/node_ext.rb

Instance Attribute Summary

Node - Inherited

#newline_flag?

: () -> bool.

Instance Method Summary

  • #to_interpolated

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

Node - Inherited

#deprecated

: (*String replacements) -> void.

#newline_flag!

: (Array lines) -> void.

Instance Attribute Details

#heredoc?Boolean (readonly)

Returns true if this node was represented as a heredoc in the source code.

[ GitHub ]

  
# File 'lib/prism/node_ext.rb', line 115

def heredoc?
  HeredocQuery.heredoc?(opening)
end

Instance Method Details

#to_interpolated

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

[ GitHub ]

  
# File 'lib/prism/node_ext.rb', line 123

def to_interpolated
  InterpolatedStringNode.new(
    source,
    -1,
    location,
    frozen? ? InterpolatedStringNodeFlags::FROZEN : 0,
    opening_loc,
    [copy(location: content_loc, opening_loc: nil, closing_loc: nil)],
    closing_loc
  )
end