Sha256: ab111f71e892cb8ae353417d4a110f2a707b2fa900f0c6dcf2ea40a939991002

Contents?: true

Size: 499 Bytes

Versions: 4

Compression:

Stored size: 499 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
  
  def name
    @name
  end

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

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
mqtt-0.5.0 lib/mqtt/patches/string_encoding.rb
yalgaar-1.0.2 lib/mqttbridge/patches/string_encoding.rb
yalgaar-1.0.1 lib/mqttbridge/patches/string_encoding.rb
mqtt-0.4.0 lib/mqtt/patches/string_encoding.rb