Method: Unified2::Protocol#to_h

Defined in:
lib/unified2/protocol.rb

#to_hHash Also known as: header

Convert To Hash

Examples:

event.protocol.to_h #=> {:length=>379, :seq=>3934511163, :ack=>1584708129 ... }

Returns:

  • (Hash)

    Protocol header hash object



69
70
71
72
73
74
75
76
77
78
79
# File 'lib/unified2/protocol.rb', line 69

def to_h
  hash = {
    :type => @protocol.to_s
  }

  if send(:"#{@protocol.downcase}?")
    hash.merge!(self.send(:"#{@protocol.downcase}"))
  end

  hash
end