Sha256: 183500b34b700b9c0060a31cb7c6b97b517c7520a078ae959f79bf24b24e9e2e
Contents?: true
Size: 952 Bytes
Versions: 7
Compression:
Stored size: 952 Bytes
Contents
#Author: Piotr Wojcieszonek #e-mail: piotr@wojcieszonek.pl # Copyright 22.03.2016 by Piotr Wojcieszonek module Lib module DHCP class Option module Type module Raw def self.included(base) base.extend ClassMethods end def len=(len) @len = len.to_i end def len @len.to_i end def pack @payload = '' if @value.nil? [@oid, @len, @payload.to_s].pack("C2a#{@len.to_i}") end def to_s @payload.unpack('C*').map{|item| item.to_i.to_s(16).rjust(2, '0') }.join(':') end module ClassMethods private def unpack(oid, len, payload) option = self.new oid, payload option.len = len.to_i option end end end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems