Sha256: 58a5f8cc8697a0f4ae6d26e5b117a4adb5f069ea0a84c22532e8edcea465e863

Contents?: true

Size: 739 Bytes

Versions: 5

Compression:

Stored size: 739 Bytes

Contents

require 'forwardable'

# Base module.
module Pio
  # Metering
  class Meter
    # 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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pio-0.26.0 lib/pio/open_flow13/meter.rb
pio-0.25.0 lib/pio/open_flow13/meter.rb
pio-0.24.2 lib/pio/open_flow13/meter.rb
pio-0.24.1 lib/pio/open_flow13/meter.rb
pio-0.24.0 lib/pio/open_flow13/meter.rb