Module: PacketGen::Headerable::ClassMethods

Defined in:
lib/packetgen/headerable.rb

Overview

This modules handles class methods for headerable classes.

Since:

  • 3.0.2

Instance Method Summary collapse

Instance Method Details

#protocol_nameString

Give protocol name for this class

Returns:

  • (String)

Since:

  • 3.0.2



18
19
20
21
22
23
24
25
26
27
# File 'lib/packetgen/headerable.rb', line 18

def protocol_name
  return @protocol_name if defined? @protocol_name

  classname = to_s
  @protocol_name = if classname.start_with?('PacketGen::Header')
                     classname.sub(/.*Header::/, '')
                   else
                     classname.sub(/.*::/, '')
                   end
end