class DRbDump::MessageResult

Wraps a DRb message-result after consuming it from a stream.

Public Class Methods

new(drbdump, packet, status, stream) click to toggle source

Creates a new MessageResult for the creating drbdump instance. The last packet in the message is packet and the Marshal::Structure for the result type is status. The rest of the message will be loaded from stream.

Calls superclass method DRbDump::Message.new
# File lib/drbdump/message_result.rb, line 12
def initialize drbdump, packet, status, stream
  super drbdump, packet

  @result     = nil
  @status     = nil
  @stream     = stream

  @raw_result = @loader.load stream
  @raw_status = status
end

Public Instance Methods

allocations() click to toggle source

The number of allocations required to load the result.

# File lib/drbdump/message_result.rb, line 26
def allocations
  @raw_status.count_allocations + @raw_result.count_allocations
end
display() click to toggle source

Prints the message information to standard output

# File lib/drbdump/message_result.rb, line 33
def display
  update_statistics

  return if @drbdump.quiet

  message   = status ? 'success' : 'exception'
  arrow     = status ? "\u21d0"  : "\u2902"
  timestamp = self.timestamp.strftime DRbDump::TIMESTAMP_FORMAT

  puts "%s %s %s %s %s: %s" % [
    timestamp, destination, arrow, source, message, result
  ]
end
result() click to toggle source

The loaded result object

# File lib/drbdump/message_result.rb, line 50
def result
  return @result if @result

  result = @drbdump.load_marshal_data @raw_result

  @result = if DRb::DRbObject === result then
             "(\"druby://#{result.__drburi}\", #{result.__drbref})"
           else
             result.inspect
           end
end
status() click to toggle source

The loaded status object

# File lib/drbdump/message_result.rb, line 65
def status
  @status ||= @raw_status.load
end
timestamp() click to toggle source

The timestamp of the last packet in the result

# File lib/drbdump/message_result.rb, line 72
def timestamp
  @packet.timestamp
end