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



25
26
27
28
29
30
31
32
33
34
# File 'lib/packetgen/headerable.rb', line 25

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