class NetAddr::EUI64
EUI-64 Address - Inherits all methods from NetAddr::EUI. Addresses of this class have a 24-bit OUI and a 40-bit EI.
Public Class Methods
new(eui)
click to toggle source
Synopsis¶ ↑
This method performs absolutely no error checking, and is meant to be used only by other internal methods for the sake of the speedier creation of EUI objects. Please consider using #create unless you know what you are doing with 100% certainty. Example: NetAddr::EUI48.new('aabbccddeeff')
Arguments:¶ ↑
-
EUI as a String or Integer. Strings should contain no formatting characters.
# File lib/eui.rb, line 45 def initialize(eui) if (eui.kind_of?(Integer)) @eui_i = eui @eui = eui.to_s(16) if ( self.kind_of?(NetAddr::EUI48) ) @eui = '0' * (12 - @eui.length) << @eui if (@eui.length < 12) else @eui = '0' * (16 - @eui.length) << @eui if (@eui.length < 16) end elsif(eui.kind_of?(String)) @eui = eui @eui_i = eui.to_i(16) else raise ArgumentError, "Expected String or Integer, but #{eui.class} provided." end # set ei & oui if ( self.kind_of?(NetAddr::EUI48) ) @ei = @eui.slice(6..11) else @ei = @eui.slice(6..15) end @oui = @eui.slice(0..5) end