# File lib/qrack/protocol/protocol09.rb, line 22 def arguments self.class.arguments.inject({}) do |hash, (type, name)| hash.update name => instance_variable_get("@#{name}") end end
# File lib/qrack/protocol/protocol09.rb, line 28 def to_binary buf = Transport09::Buffer.new buf.write :short, self.class.parent.id buf.write :short, self.class.id bits = [] self.class.arguments.each do |type, name| val = instance_variable_get("@#{name}") if type == :bit bits << (val || false) else unless bits.empty? buf.write :bit, bits bits = [] end buf.write type, val end end buf.write :bit, bits unless bits.empty? buf.rewind buf end
# File lib/qrack/protocol/protocol09.rb, line 58 def to_frame channel = 0 Transport09::Method.new(self, channel) end
# File lib/qrack/protocol/protocol09.rb, line 54 def to_s to_binary.to_s end
# File lib/qrack/protocol/protocol09.rb, line 5 def initialize *args opts = args.pop if args.last.is_a? Hash opts ||= {} if args.size == 1 and args.first.is_a? Transport09::Buffer buf = args.shift else buf = nil end self.class.arguments.each do |type, name| val = buf ? buf.read(type) : args.shift || opts[name] || opts[name.to_s] instance_variable_set("@#{name}", val) end end