Sha256: 2cd406cf0a68e49aef4afb6712490a7be9512d0292028bb51854c0f4ce4aa47d

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require_relative 'internal/platform'
require_relative 'internal/time_keeper'
require_relative 'internal/value'

module Loba
  # Internal functionality support
  # @api private
  module Internal
    # Remove wrapping quotes on a string (produced by .inspect)
    #
    # @param content [String] the string (assumed to be produced from calling .inspect)
    #   to remove quotes (") that wrap a string
    #
    # @return [String, Object]
    #   * If not a string, the original argument will be returned without modification
    #   * If string does not have quotes as first and last character, the original
    #     argument will be returned without modification
    #   * If string does have quotes as first and last character, the original content
    #     will be returned with the original first and last character removed
    def unquote(content)
      return content unless content.is_a?(String)
      return content unless content[0] == '"' && content[-1] == '"'

      content[1...-1]
    end
    module_function :unquote
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
loba-2.0.0 lib/loba/internal.rb