class BitGirder::Io::BinaryReader

Public Instance Methods

eof?() click to toggle source
# File lib/bitgirder/io.rb, line 838
def eof?
    @io.eof?
end
peek_int8() click to toggle source
# File lib/bitgirder/io.rb, line 855
def peek_int8
    peekc.unpack( 'c' )[ 0 ]
end
peekc() click to toggle source
# File lib/bitgirder/io.rb, line 843
def peekc
    
    res = @io.getc.tap { |c| @io.ungetc( c ) }

    case res
    when String then res
    when Fixnum then res.chr
    else raise "Unexpected getc val: #{res.class}"
    end
end
read( *argv ) click to toggle source
# File lib/bitgirder/io.rb, line 865
def read( *argv )
    @io.read( *argv ).tap { |res| @pos += res.bytesize }
end
read_bool() click to toggle source
# File lib/bitgirder/io.rb, line 885
def read_bool
    read_int8 != 0
end
Also aliased as: read_boolean
read_boolean()
Alias for: read_bool
read_buffer32() click to toggle source
# File lib/bitgirder/io.rb, line 892
def read_buffer32
    read_full( read_int32 )
end
read_full( len, buf = nil ) click to toggle source
# File lib/bitgirder/io.rb, line 860
def read_full( len, buf = nil )
    Io.read_full( @io, len, buf ).tap { @pos += len }
end
read_utf8() click to toggle source
# File lib/bitgirder/io.rb, line 897
def read_utf8
 
    len = read_int32

    str = "" * len
    read_full( len, str )
    RubyVersions.when_19x { str.force_encoding( "utf-8" ) }

    str
end