Class: NetAddr::EUI48
Overview
EUI-48 Address - Inherits all methods from NetAddr::EUI. Addresses of this class have a 24-bit OUI and a 24-bit EI.
Instance Method Summary collapse
-
#initialize(eui) ⇒ EUI48
constructor
Synopsis Return an EUI48 object.
Methods inherited from EUI
#address, create, #ei, #link_local, #oui
Constructor Details
#initialize(eui) ⇒ EUI48
Synopsis
Return an EUI48 object. PackedEUI takes precedence over EUI.
addr = NetAddr::EUI48.new(‘aa-bb-cc-dd-ee-ff’) addr = NetAddr::EUI48.new(‘aa:bb:cc:dd:ee:ff’) addr = NetAddr::EUI48.new(‘aabb.ccdd.eeff’)
Arguments:
-
EUI as a String or Integer
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
# File 'lib/eui.rb', line 325 def initialize(eui) if (eui.kind_of?(Integer)) @oui = eui >> 24 @ei = eui & 0xffffff elsif(eui.kind_of?(String)) # validate NetAddr.validate_eui(eui) # remove formatting characters eui.gsub!(/[\.\:\-]/, '') # split into oui & ei, pack, and store @oui = eui.slice!(0..5).to_i(16) @ei = eui.to_i(16) else raise ArgumentError, "Expected String or Integer, but #{eui.class} provided." end end |