Sha256: bb9b88d0f7e4d04ed7dd7e031f0b9d3f046aa987603040561f8bb721d505c4dd

Contents?: true

Size: 697 Bytes

Versions: 5

Compression:

Stored size: 697 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 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.23.1 lib/pio/open_flow13/meter.rb
pio-0.23.0 lib/pio/open_flow13/meter.rb
pio-0.22.0 lib/pio/open_flow13/meter.rb
pio-0.21.1 lib/pio/open_flow13/meter.rb
pio-0.21.0 lib/pio/open_flow13/meter.rb