Sha256: 4e08a7cba4af67b1cbe651d50f84d5050e47b8ce3c58410cb7073943121d6dd3

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

module Renc
  # namespace
  module Configuration
    # this gem's default configured encoding
    # @see Encoding.default_external
    DEFAULT_ENCODING = Encoding.default_external

    # this gem's default options for String#encode
    # @see String#encode
    DEFAULT_OPTIONS = { undef: :replace }.freeze

    # return @default_encoding
    # @return [Encoding] @default_encoding
    # @see DEFAULT_ENCODING
    def default_encoding
      @default_encoding ||= DEFAULT_ENCODING
    end

    # configure default encoding
    # @example
    #   Renc.default_encoding = 1 # => Renc::ConfigureError
    #   Renc.default_encoding = Encoding::ASCII
    # @param encoding [Encoding]
    def default_encoding=(encoding)
      raise TypeError unless encoding.is_a?(Encoding)
      @default_encoding = encoding
    end

    # return @default_options
    # @return [Encoding] @default_options
    # @see DEFAULT_OPTIONS
    def default_options
      @default_options ||= DEFAULT_OPTIONS
    end

    # configure default options
    # @example
    #   Renc.default_options = 1 # => Renc::ConfigureError
    #   Renc.default_options = { undef: nil }
    # @param options [Hash]
    def default_options=(options)
      raise TypeError unless options.is_a?(Hash)
      @default_options = options
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
renc-2.1.0 lib/renc/configuration.rb