module TomlRB::BasicString
Used in primitive.citrus
Constants
- SPECIAL_CHARS
Public Class Methods
decode_unicode(str)
click to toggle source
Replace the unicode escaped characters with the corresponding character e.g. u03B4 => ?
# File lib/toml-rb/string.rb, line 23 def self.decode_unicode(str) [str[2..-1].to_i(16)].pack('U') end
parse_error(m)
click to toggle source
# File lib/toml-rb/string.rb, line 37 def self.parse_error(m) fail ParseError.new "Escape sequence #{m} is reserved" end
transform_escaped_chars(str)
click to toggle source
# File lib/toml-rb/string.rb, line 27 def self.transform_escaped_chars(str) str.gsub(/\\(u[\da-fA-F]{4}|U[\da-fA-F]{8}|.)/) do |m| if m.size == 2 SPECIAL_CHARS[m] || parse_error(m) else decode_unicode(m).force_encoding('UTF-8') end end end
Public Instance Methods
value()
click to toggle source
# File lib/toml-rb/string.rb, line 15 def value aux = TomlRB::BasicString.transform_escaped_chars first.value aux[1...-1] end