Class: NetAddr::EUI48

### Home Classes Methods

### In Files

- lib/eui.rb

### Parent

NetAddr::EUI

### Methods

- ::new
- #to_eui64

### Files

- Errors
- README
- changelog

### Class/Module Index

Quicksearch

- NetAddr
- NetAddr::CIDR
- NetAddr::CIDRv4
- NetAddr::CIDRv6
- NetAddr::EUI
- NetAddr::EUI48
- NetAddr::EUI64
- NetAddr::Tree

No matching classes.

# NetAddr::EUI48

EUI-48 Address - Inherits all methods from NetAddr::EUI. Addresses of this class have a 24-bit OUI and a 24-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

### Public Instance Methods

to_eui64() click to toggle source

### Synopsis

Return an EUI64 address based on the current EUI48 address.

    Example:
    addr = NetAddr::EUI.create('aabb.ccdd.eeff')
    addr.to_eui64 => NetAddr::EUI64

### Arguments:

- none

### Returns:

- NetAddr::EUI64 object

    # File lib/eui.rb, line 446
    def to_eui64()
        eui = @oui + 'fffe' + @ei
        return( NetAddr::EUI64.new(eui.to_i(16)) )
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.