Class: Toml::StringLiteral

Inherits:
Treetop::Runtime::SyntaxNode
  • Object
show all
Defined in:
lib/tomlp/token_extensions.rb

Instance Method Summary collapse

Instance Method Details

#evaluateObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/tomlp/token_extensions.rb', line 12

def evaluate
  string = self.text_value
  output = ""
  length = self.text_value.length
  count = 0
  while count < length
    if string[count] == "\\"
      count += 1
      case string[count]
      when "t"
        output << "\t"
      when "n"
        output << "\n"
      when "n"
        output << '"'
      when '"'
        output << "\\"
      when "r"
        output << "\r"
      end
    elsif string[count] != "\""
      output << string[count]
    end
    count += 1
  end
  return output
end