class Rserve::Packet
Constants
- ERROR_DESCRIPTIONS
Attributes
cmd[R]
cont[R]
Public Class Methods
new(cmd, cont)
click to toggle source
# File lib/rserve/packet.rb, line 12 def initialize(cmd, cont) raise "cont [#{cont.class} - #{cont.to_s}] should respond to :length" if !cont.nil? and !cont.respond_to? :length @cmd=cmd @cont=cont end
Public Instance Methods
cont_len()
click to toggle source
# File lib/rserve/packet.rb, line 17 def cont_len @cont.nil? ? 0 : @cont.length end
error?()
click to toggle source
# File lib/rserve/packet.rb, line 23 def error? @cmd&15==2 end
get_error_description(stat)
click to toggle source
# File lib/rserve/packet.rb, line 29 def get_error_description(stat) ERROR_DESCRIPTIONS[stat] end
ok?()
click to toggle source
# File lib/rserve/packet.rb, line 20 def ok? @cmd&15==1 end
stat()
click to toggle source
# File lib/rserve/packet.rb, line 26 def stat (@cmd>>24)&127 end
to_s()
click to toggle source
# File lib/rserve/packet.rb, line 32 def to_s if error? status="error:'#{get_error_description(stat)}'(#{stat})" else status="ok" end "Packet[cmd=#{@cmd},len="+((cont.nil?)?"<nil>":(""+cont.length.to_s))+", con='"+(cont.nil? ? "<nil>" : cont.pack("C*"))+"', status=#{status}]" end