Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/mqtt/patches/string_encoding.rb

Overview

Monkey patch to add stubbed string encoding functions to Ruby 1.8

Instance Method Summary collapse

Instance Method Details

#encode(encoding) ⇒ Object



13
14
15
16
# File 'lib/mqtt/patches/string_encoding.rb', line 13

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

#encodingObject



9
10
11
# File 'lib/mqtt/patches/string_encoding.rb', line 9

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

#force_encoding(encoding) ⇒ Object



4
5
6
7
# File 'lib/mqtt/patches/string_encoding.rb', line 4

def force_encoding(encoding)
  @encoding = encoding
  self
end