Module: Postgres::Conversion

### Home Classes Methods

### In Files

- lib/postgres-pr/typeconv/array.rb
- lib/postgres-pr/typeconv/bytea.rb
- lib/postgres-pr/typeconv/conv.rb

### Namespace

- CLASS Postgres::Conversion::ConversionError

### Methods

- #decode_array
- #decode_bytea
- #encode_bytea

### 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
- DatabaseError
- Error
- IO
- PGError
- PGconn
- PGresult
- TC_Conversion

No matching classes.

# Postgres::Conversion

### Public Instance Methods

decode_array(str, delim=',', &conv_proc) click to toggle source

    # File lib/postgres-pr/typeconv/array.rb, line 5
    def decode_array(str, delim=',', &conv_proc)
      delim = Regexp.escape(delim)
      buf = StringScanner.new(str)
      return parse_arr(buf, delim, &conv_proc)
    ensure
      raise ConversionError, "end of string expected (#{buf.rest})" unless buf.empty?
    end

decode_bytea(str) click to toggle source

Decodes a bytea encoded string.

for decoding rules see:

    http://www.postgresql.org/docs/7.4/static/datatype-binary.html

    # File lib/postgres-pr/typeconv/bytea.rb, line 20
    def decode_bytea(str)
      str.gsub(/\\(\\|'|[0-3][0-7][0-7])/) {|s|
        if s.size == 2 then s[1,1] else s[1,3].oct.chr end
      }
    end

encode_bytea(str) click to toggle source

Encodes a string as bytea value.

for encoding rules see:

    http://www.postgresql.org/docs/7.4/static/datatype-binary.html

    # File lib/postgres-pr/typeconv/bytea.rb, line 10
    def encode_bytea(str)
      str.gsub(/[\0000-\0037\0047\1134\1177-\3377]/) {|b| "\\#{ b[0].to_s(8).rjust(3, '0') }" }
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.