Sha256: babc7f3b813494035afcc94dd7b297adacf33b4f87922acc2dce7bcb66d696ce
Contents?: true
Size: 932 Bytes
Versions: 28
Compression:
Stored size: 932 Bytes
Contents
require 'bindata' require 'forwardable' module Pio # An action to modify the VLAN related fields of a packet. class SetVlan extend Forwardable # rubocop:disable MethodLength def self.def_format(field_name, action_type) str = %( class Format < BinData::Record endian :big uint16 :type, value: #{action_type} uint16 :message_length, value: 8 uint16 :#{field_name} uint16 :padding hide :padding end ) module_eval str module_eval "def_delegators :@format, :#{field_name}" end # rubocop:enable MethodLength def self.read(raw_data) set_vlan = allocate set_vlan.instance_variable_set :@format, const_get(:Format).read(raw_data) set_vlan end def_delegators :@format, :type def_delegators :@format, :message_length def_delegator :@format, :to_binary_s, :to_binary end end
Version data entries
28 entries across 28 versions & 1 rubygems