module PacketGen::Types::Fieldable

Mixin to define minimal API for a class to be embbeded as a field in {Fields} type.

Optional methods

These methods may, optionally, be defined by fieldable types:

@author Sylvain Daubert @since 3.1.6

Public Instance Methods

format_inspect() click to toggle source

Format object when inspecting a {Field} object @return [String]

# File lib/packetgen/types/fieldable.rb, line 60
def format_inspect
  to_human
end
read(str) click to toggle source

Populate object from a binary string @param [String] str @return [Fields] self @abstract subclass should overload it.

Calls superclass method
# File lib/packetgen/types/fieldable.rb, line 32
def read(str)
  super
end
sz() click to toggle source

Size of object as binary string @return [Integer]

# File lib/packetgen/types/fieldable.rb, line 45
def sz
  to_s.size
end
to_human() click to toggle source

Return a human-readbale string @return [String] @abstract subclass should overload it.

Calls superclass method
# File lib/packetgen/types/fieldable.rb, line 52
def to_human
  super
end
to_s() click to toggle source

Return object as a binary string @return [String] @abstract subclass should overload it.

Calls superclass method
# File lib/packetgen/types/fieldable.rb, line 39
def to_s
  super
end
type_name() click to toggle source

Get type name @return [String]

# File lib/packetgen/types/fieldable.rb, line 21
def type_name
  self.class.to_s.split('::').last
end