Sha256: 8d1de5f564eaa4715188572301011aefb5fc5d91eccc87a11e535e9e4bc4b07c

Contents?: true

Size: 852 Bytes

Versions: 1

Compression:

Stored size: 852 Bytes

Contents

module TOML
  # Used in primitive.citrus
  module BasicString
    def value
      aux = TOML::BasicString.transform_escaped_chars first.value

      aux[1...-1]
    end

    def self.transform_escaped_chars(str)
      str.gsub(/\\0/, "\0")
        .gsub(/\\t/, "\t")
        .gsub(/\\n/, "\n")
        .gsub(/\\\"/, '"')
        .gsub(/\\r/, "\r")
        .gsub(/\\\\/, '\\')
    end
  end

  module LiteralString
    def value
      first.value[1...-1]
    end
  end

  module MultilineString
    def value
      aux = captures[:text].first.value

      # Remove spaces on multilined Singleline strings
      aux.gsub!(/\\\r?\n[\n\t\r ]*/, '')

      TOML::BasicString.transform_escaped_chars aux
    end
  end

  module MultilineLiteral
    def value
      aux = captures[:text].first.value

      aux.gsub(/\\\r?\n[\n\t\r ]*/, '')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
toml-rb-0.3.6 lib/toml/string.rb