Sha256: eed6a034326664afdc1690f41770910ac96cf485420f60c7b1bda32edc4b9d6b

Contents?: true

Size: 920 Bytes

Versions: 1

Compression:

Stored size: 920 Bytes

Contents

# frozen_string_literal: true

require 'forwardable'
require 'pio/open_flow/instruction'

# Base module.
module Pio
  module OpenFlow13
    # Apply meter (rate limiter)
    class Meter < OpenFlow::Instruction
      # OpenFlow 1.3.4 OFPIT_METER instruction format
      class Format < BinData::Record
        endian :big

        uint16 :instruction_type, value: 6
        uint16 :instruction_length, value: 8
        uint32 :meter_id
      end

      def self.read(raw_data)
        allocate.tap do |meter|
          meter.instance_variable_set :@format, Format.read(raw_data)
        end
      end

      extend Forwardable

      def_delegators :@format, :instruction_type
      def_delegators :@format, :instruction_length
      def_delegators :@format, :meter_id
      def_delegators :@format, :to_binary_s

      def initialize(meter_id)
        @format = Format.new(meter_id: meter_id)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pio-0.30.2 lib/pio/open_flow13/meter.rb