Sha256: e6d3983771ebad6b78a42522e8a5348e1ecb466c06e93b70fb9849a62ebfb515

Contents?: true

Size: 485 Bytes

Versions: 1

Compression:

Stored size: 485 Bytes

Contents

# Monkey patch to add stubbed string encoding functions to Ruby 1.8

class String
  def force_encoding(encoding)
    @encoding = encoding
    self
  end

  def encoding
    @encoding ||= Encoding::ASCII_8BIT
  end

  def encode(encoding)
    new = dup
    new.force_encoding(encoding)
  end
end

class Encoding
  attr_reader :name

  def initialize(name)
    @name = name
  end

  def to_s
    @name
  end

  UTF_8 = Encoding.new('UTF-8')
  ASCII_8BIT = Encoding.new('ASCII-8BIT')
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mqtt-0.6.0 lib/mqtt/patches/string_encoding.rb