Sha256: 808d32bc653bb22339f14974845e0c415681cb6f4c2816e8fd5ec72b77397e64

Contents?: true

Size: 757 Bytes

Versions: 7

Compression:

Stored size: 757 Bytes

Contents

require 'forwardable'

# Base module.
module Pio
  # Apply meter (rate limiter)
  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

7 entries across 7 versions & 1 rubygems

Version Path
pio-0.30.0 lib/pio/open_flow13/meter.rb
pio-0.29.0 lib/pio/open_flow13/meter.rb
pio-0.28.1 lib/pio/open_flow13/meter.rb
pio-0.28.0 lib/pio/open_flow13/meter.rb
pio-0.27.2 lib/pio/open_flow13/meter.rb
pio-0.27.1 lib/pio/open_flow13/meter.rb
pio-0.27.0 lib/pio/open_flow13/meter.rb