Sha256: d8bdc84f033dc6e1357449a23d0f4c6780e7afe82d5c996f5baba671e0c47ac8

Contents?: true

Size: 469 Bytes

Versions: 4

Compression:

Stored size: 469 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 = self.dup
    new.force_encoding(encoding)
  end
end

class Encoding
  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

4 entries across 4 versions & 1 rubygems

Version Path
mqtt-0.3.1 lib/mqtt/patches/string_encoding.rb
mqtt-0.3.0 lib/mqtt/patches/string_encoding.rb
mqtt-0.2.0 lib/mqtt/patches/string_encoding.rb
mqtt-0.1.0 lib/mqtt/patches/string_encoding.rb