Parent

Class/Module Index [+]

Quicksearch

Moped::BSON::Binary

Constants

SUBTYPE_MAP

Attributes

data[R]
type[R]

Public Class Methods

__bson_load__(io) click to toggle source
# File lib/moped/bson/binary.rb, line 22
def __bson_load__(io)
  length, = io.read(4).unpack(INT32_PACK)
  type = SUBTYPE_MAP.invert[io.read(1)]

  if type == :old
    length -= 4
    io.read(4)
  end

  data = io.read length
  new(type, data)
end
new(type, data) click to toggle source
# File lib/moped/bson/binary.rb, line 16
def initialize(type, data)
  @type = type
  @data = data
end

Public Instance Methods

==(other) click to toggle source
# File lib/moped/bson/binary.rb, line 36
def ==(other)
  BSON::Binary === other && data == other.data && type == other.type
end
Also aliased as: eql?
__bson_dump__(io, key) click to toggle source
# File lib/moped/bson/binary.rb, line 45
def __bson_dump__(io, key)
  io << Types::BINARY
  io << key
  io << NULL_BYTE

  if type == :old
    io << [data.bytesize + 4].pack(INT32_PACK)
    io << SUBTYPE_MAP[type]
    io << [data.bytesize].pack(INT32_PACK)
    io << data
  else
    io << [data.bytesize].pack(INT32_PACK)
    io << SUBTYPE_MAP[type]
    io << data
  end
end
eql?(other) click to toggle source
Alias for: ==
hash() click to toggle source
# File lib/moped/bson/binary.rb, line 41
def hash
  [data, type].hash
end
inspect() click to toggle source
# File lib/moped/bson/binary.rb, line 62
def inspect
  "#<#{self.class.name} type=#{type.inspect} length=#{data.bytesize}>"
end
to_s() click to toggle source
# File lib/moped/bson/binary.rb, line 66
def to_s
  data.to_s
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.