Module: PacketGen::Types::Fieldable
- Included in:
- Header::DHCPv6::DUID, Header::DHCPv6::Option, Header::DNS::Question, Header::Eth::MacAddr, Header::HTTP::Headers, Header::IGMPv3::GroupRecord, Header::IP::Addr, Header::IP::Option, Header::IPv6::Addr, Header::MLDv2::McastAddressRecord, Header::OSPFv2::External, Header::OSPFv2::LSAHeader, Header::OSPFv2::LSR, Header::OSPFv2::Link, Header::OSPFv2::TosMetric, Header::OSPFv3::IPv6Prefix, Header::OSPFv3::LSAHeader, Header::OSPFv3::LSR, Header::OSPFv3::Link, Header::TCP::Option, AbstractTLV, Array, CString, Int, IntString, OUI, String, TLV
- Defined in:
- lib/packetgen/types/fieldable.rb
Overview
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:
-
from_human
to load data from a human-readable string.
Instance Method Summary collapse
-
#format_inspect ⇒ String
Format object when inspecting a Fields object.
-
#read(str) ⇒ Fields
abstract
Populate object from a binary string.
-
#sz ⇒ Integer
Size of object as binary string.
-
#to_human ⇒ String
abstract
Return a human-readbale string.
-
#to_s ⇒ String
abstract
Return object as a binary string.
-
#type_name ⇒ String
Get type name.
Instance Method Details
#format_inspect ⇒ String
Format object when inspecting a PacketGen::Types::Fields object
61 62 63 |
# File 'lib/packetgen/types/fieldable.rb', line 61 def format_inspect to_human end |
#read(str) ⇒ Fields
This method is abstract.
subclass should overload it.
Populate object from a binary string
33 34 35 |
# File 'lib/packetgen/types/fieldable.rb', line 33 def read(str) super end |
#sz ⇒ Integer
Size of object as binary string
46 47 48 |
# File 'lib/packetgen/types/fieldable.rb', line 46 def sz to_s.size end |
#to_human ⇒ String
This method is abstract.
subclass should overload it.
Return a human-readbale string
53 54 55 |
# File 'lib/packetgen/types/fieldable.rb', line 53 def to_human super end |
#to_s ⇒ String
This method is abstract.
subclass should overload it.
Return object as a binary string
40 41 42 |
# File 'lib/packetgen/types/fieldable.rb', line 40 def to_s super end |
#type_name ⇒ String
Get type name
22 23 24 |
# File 'lib/packetgen/types/fieldable.rb', line 22 def type_name self.class.to_s.split('::').last end |