Module: Renc::Configuration

Included in:
Renc
Defined in:
lib/renc/configuration.rb

Overview

namespace

Constant Summary collapse

DEFAULT_ENCODING =

this gem’s default configured encoding

See Also:

  • Encoding.default_external
Encoding.default_external
DEFAULT_OPTIONS =

this gem’s default options for String#encode

See Also:

  • String#encode
{ undef: :replace }.freeze

Instance Method Summary collapse

Instance Method Details

#default_encodingEncoding

return @default_encoding

Returns:

  • (Encoding)

    @default_encoding

See Also:



18
19
20
# File 'lib/renc/configuration.rb', line 18

def default_encoding
  @default_encoding ||= DEFAULT_ENCODING
end

#default_encoding=(encoding) ⇒ Object

configure default encoding

Examples:

Renc.default_encoding = 1 # => TypeError
Renc.default_encoding = Encoding::ASCII

Parameters:

  • encoding (Encoding)

Raises:

  • (TypeError)


27
28
29
30
31
# File 'lib/renc/configuration.rb', line 27

def default_encoding=(encoding)
  raise TypeError, ERR_MESSAGE_ENCODING unless encoding.is_a?(Encoding)

  @default_encoding = encoding
end

#default_optionsEncoding

return @default_options

Returns:

  • (Encoding)

    @default_options

See Also:



36
37
38
# File 'lib/renc/configuration.rb', line 36

def default_options
  @default_options ||= DEFAULT_OPTIONS
end

#default_options=(options) ⇒ Object

configure default options

Examples:

Renc.default_options = 1 # => TypeError
Renc.default_options = { undef: nil }

Parameters:

  • options (Hash)

Raises:

  • (TypeError)


45
46
47
48
49
# File 'lib/renc/configuration.rb', line 45

def default_options=(options)
  raise TypeError, ERR_MESSAGE_OPTIONS unless options.is_a?(Hash)

  @default_options = options
end