class GQTP::Header
Attributes
cas[RW]
flags[RW]
key_length[RW]
level[RW]
opaque[RW]
proto[RW]
query_type[RW]
size[RW]
status[RW]
Public Class Methods
new(values={}) { |self| ... }
click to toggle source
# File lib/gqtp/header.rb, line 54 def initialize(values={}) @proto = values[:proto] || Protocol::GQTP @query_type = values[:query_type] || ContentType::NONE @key_length = values[:key_length] || 0 @level = values[:level] || 0 @flags = values[:flags] || 0 @status = values[:status] || Status::SUCCESS @size = values[:size] || 0 @opaque = values[:opaque] || 0 @cas = values[:cas] || 0 yield(self) if block_given? end
pack_format()
click to toggle source
# File lib/gqtp/header.rb, line 47 def pack_format "CCnCCnNNNN" end
parse(chunk)
click to toggle source
# File lib/gqtp/header.rb, line 33 def parse(chunk) return nil if chunk.bytesize < size header = new header.proto, header.query_type, header.key_length, header.level, header.flags, header.status, header.size, header.opaque, cas_high, cas_low = chunk.unpack(pack_format) header.cas = cas_high << 32 + cas_low header end
size()
click to toggle source
# File lib/gqtp/header.rb, line 43 def size 24 end
Public Instance Methods
==(other)
click to toggle source
# File lib/gqtp/header.rb, line 75 def ==(other) other.is_a?(self.class) and to_hash == other.to_hash end
pack()
click to toggle source
# File lib/gqtp/header.rb, line 67 def pack data = [ @proto, @query_type, @key_length, @level, @flags, @status, @size, @opaque, @cas >> 32, @cas & (2 ** 32), ] data.pack(self.class.pack_format) end
to_hash()
click to toggle source
# File lib/gqtp/header.rb, line 79 def to_hash { :proto => @proto, :query_type => @query_type, :key_length => @key_length, :level => @level, :flags => @flags, :status => @status, :size => @size, :opaque => @opaque, :cas => @cas, } end