Sha256: 744d3cf2a53cfdf10c6c5e34a617e3a721b5ddab94084054a7b251e8483dc0a1
Contents?: true
Size: 849 Bytes
Versions: 1
Compression:
Stored size: 849 Bytes
Contents
# frozen_string_literal: true # Released under the MIT License. # Copyright, 2023, by Samuel Williams. module Console module Output # @deprecated With no replacement. class Encoder def initialize(output, encoding = ::Encoding::UTF_8) @output = output @encoding = encoding end attr :output attr :encoding def call(subject = nil, *arguments, **options, &block) subject = encode(subject) arguments = encode(arguments) options = encode(options) @output.call(subject, *arguments, **options, &block) end def encode(value) case value when String value.encode(@encoding, invalid: :replace, undef: :replace) when Array value.map{|item| encode(item)} when Hash value.transform_values{|item| encode(item)} else value end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
console-1.22.0 | lib/console/output/encoder.rb |