class Mingle::MingleBuffer
Attributes
buf[R]
Public Class Methods
new( buf, encode_mode = :none )
click to toggle source
# File lib/mingle.rb, line 271 def initialize( buf, encode_mode = :none ) not_nil( buf, "buf" ) @buf = RubyVersions.when_19x( buf ) do process_buffer_encoding( buf, encode_mode ) end end
Public Instance Methods
==( other )
click to toggle source
# File lib/mingle.rb, line 281 def ==( other ) other.is_a?( MingleBuffer ) && other.buf == @buf end
Also aliased as: eql?
Private Instance Methods
process_buffer_encoding( buf, encode_mode )
click to toggle source
# File lib/mingle.rb, line 249 def process_buffer_encoding( buf, encode_mode ) enc_bin = Encoding::BINARY if ( enc = buf.encoding ) != enc_bin case encode_mode when :copy then buf = buf.encode( enc_bin ) when :in_place then buf = buf.encode!( enc_bin ) when :none raise EncodingError, "Encoding should be binary (got : #{enc})" else raise "Invalid encode mode: #{encode_mode}" end end buf end