Class: Code::Node::String::Part::Text

Inherits:
Code::Node show all
Defined in:
lib/code/node/string.rb

Instance Method Summary collapse

Methods inherited from Code::Node

#resolve

Constructor Details

#initialize(parsed) ⇒ Text

Returns a new instance of Text.



20
21
22
23
24
# File 'lib/code/node/string.rb', line 20

def initialize(parsed)
  return if parsed.nil?

  @text = parsed
end

Instance Method Details

#evaluate(**_args) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/code/node/string.rb', line 26

def evaluate(**_args)
  ::Code::Object::String.new(
    @text
      .to_s
      .gsub('\n', "\n")
      .gsub('\r', "\r")
      .gsub('\t', "\t")
      .gsub('\b', "\b")
      .gsub('\f', "\f")
      .gsub('\a', "\a")
      .gsub('\e', "\e")
  )
end