Module: BinaryReaderMixin

### Home Classes Methods

### In Files

- lib/binary_reader.rb

### Methods

- #read_byte
- #read_int16_big
- #read_int16_little
- #read_int16_native
- #read_int32_big
- #read_int32_little
- #read_int32_native
- #read_int8
- #read_uint8
- #read_word16_big
- #read_word16_little
- #read_word16_native
- #read_word32_big
- #read_word32_little
- #read_word32_native
- #read_word8
- #readn

### Files

- 1q

### Class/Module Index

Quicksearch

- PostgresPR
- PostgresPR::Authentification
- PostgresPR::AuthentificationClearTextPassword
- PostgresPR::AuthentificationCryptPassword
- PostgresPR::AuthentificationKerberosV4
- PostgresPR::AuthentificationKerberosV5
- PostgresPR::AuthentificationMD5Password
- PostgresPR::AuthentificationOk
- PostgresPR::AuthentificationSCMCredential
- PostgresPR::BackendKeyData
- PostgresPR::CommandComplete
- PostgresPR::Connection
- PostgresPR::Connection::Result
- PostgresPR::CopyInResponse
- PostgresPR::CopyOutResponse
- PostgresPR::DataRow
- PostgresPR::DumpError
- PostgresPR::EmptyQueryResponse
- PostgresPR::ErrorResponse
- PostgresPR::Message
- PostgresPR::NoticeErrorMixin
- PostgresPR::NoticeResponse
- PostgresPR::ParameterStatus
- PostgresPR::Parse
- PostgresPR::ParseComplete
- PostgresPR::ParseError
- PostgresPR::PasswordMessage
- PostgresPR::Query
- PostgresPR::ReadyForQuery
- PostgresPR::RowDescription
- PostgresPR::RowDescription::FieldInfo
- PostgresPR::SSLRequest
- PostgresPR::SaltedAuthentificationMixin
- PostgresPR::StartupMessage
- PostgresPR::Terminate
- PostgresPR::UnknownAuthType
- PostgresPR::UnknownMessageType
- Buffer
- Buffer::EOF
- Buffer::Error
- Postgres
- Postgres::Conversion
- Postgres::Conversion::ConversionError
- BinaryReaderMixin
- BinaryWriterMixin
- ByteOrder
- IO
- PGError
- PGconn
- PGresult
- TC_Conversion

No matching classes.

# BinaryReaderMixin

This mixin solely depends on method read(n), which must be defined in the class/module where you mixin this module.

### Public Instance Methods

read_byte() click to toggle source
Alias for: read_word8
read_int16_big() click to toggle source

    # File lib/binary_reader.rb, line 48
    def read_int16_big
      # swap bytes if native=little (but we want big)
      ru_swap(2, 's', ByteOrder::Little)
    end

read_int16_little() click to toggle source

    # File lib/binary_reader.rb, line 43
    def read_int16_little
      # swap bytes if native=big (but we want little)
      ru_swap(2, 's', ByteOrder::Big)
    end

read_int16_native() click to toggle source

### Signed

    # File lib/binary_reader.rb, line 39
    def read_int16_native
      ru(2, 's')
    end

read_int32_big() click to toggle source

    # File lib/binary_reader.rb, line 80
    def read_int32_big
      # swap bytes if native=little (but we want big)
      ru_swap(4, 'l', ByteOrder::Little)
    end

read_int32_little() click to toggle source

    # File lib/binary_reader.rb, line 75
    def read_int32_little
      # swap bytes if native=big (but we want little)
      ru_swap(4, 'l', ByteOrder::Big)
    end

read_int32_native() click to toggle source

### Signed

    # File lib/binary_reader.rb, line 71
    def read_int32_native
      ru(4, 'l')
    end

read_int8() click to toggle source

    # File lib/binary_reader.rb, line 15
    def read_int8
      ru(1, 'c')
    end

read_uint8() click to toggle source

## Aliases

Alias for: read_word8
read_word16_big() click to toggle source

    # File lib/binary_reader.rb, line 33
    def read_word16_big
      ru(2, 'n')
    end

read_word16_little() click to toggle source

    # File lib/binary_reader.rb, line 29
    def read_word16_little
      ru(2, 'v')
    end

read_word16_native() click to toggle source

### Unsigned

    # File lib/binary_reader.rb, line 25
    def read_word16_native
      ru(2, 'S')
    end

read_word32_big() click to toggle source

    # File lib/binary_reader.rb, line 65
    def read_word32_big
      ru(4, 'N')
    end

read_word32_little() click to toggle source

    # File lib/binary_reader.rb, line 61
    def read_word32_little
      ru(4, 'V')
    end

read_word32_native() click to toggle source

### Unsigned

    # File lib/binary_reader.rb, line 57
    def read_word32_native
      ru(4, 'L')
    end

read_word8() click to toggle source

no byteorder for 8 bit!

    # File lib/binary_reader.rb, line 11
    def read_word8
      ru(1, 'C')
    end

Also aliased as: read_byte, read_uint8
readn(n) click to toggle source

read exactly n characters, otherwise raise an exception.

    # File lib/binary_reader.rb, line 101
    def readn(n)
      str = read(n)
      raise "couldn't read #{n} characters" if str.nil? or str.size != n
      str
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.