Class: NetAddr::CIDRv4

### Home Classes Methods

### In Files

- lib/cidr.rb

### Parent

NetAddr::CIDR

### Methods

- ::new
- #hostmask_ext
- #netmask_ext

### 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::CIDRv4

IPv4 CIDR address - Inherits all methods from NetAddr::CIDR. Addresses of this class are composed of a 32-bit address space.

### Public Class Methods

new(ip, netmask=nil, tag={}, wildcard_mask=nil, wildcard_mask_bit_flipped=false) click to toggle source

    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 CIDR objects.
    Please consider using #create unless you know what you are doing with 100% certainty.

### Arguments:

- ip - Integer representing an ip address

- netmask - Integer representing a binary netmask

- tag - Hash used to append custom tags to CIDR

- wildcard_mask - Integer representing a binary mask

- wildcard_mask_bit_flipped - indicates whether or not the wildcard_mask is bit-flipped or not

    # File lib/cidr.rb, line 239
    def initialize(ip, netmask=nil, tag={}, wildcard_mask=nil, wildcard_mask_bit_flipped=false)
        @ip = ip

        if ( self.kind_of?(NetAddr::CIDRv4) )
            @version = 4
            @address_len = 32
        else
            @version = 6
            @address_len = 128
        end
        @all_f = 2**@address_len - 1

        if (netmask)
            @netmask = netmask
        else
            @netmask = 2**@address_len - 1
        end

        @network = (@ip & @netmask)
        @hostmask = @netmask ^ @all_f
        @tag = tag

        if (!wildcard_mask)
            @wildcard_mask = @netmask
        else
            @wildcard_mask = wildcard_mask
            @wildcard_mask = ~@wildcard_mask if (wildcard_mask_bit_flipped)
        end

    end

### Public Instance Methods

hostmask_ext() click to toggle source

### Synopsis

Provide IPv4 Hostmask in extended format (y.y.y.y).

    Example:
    cidr = NetAddr::CIDR.create('10.1.0.0/24')
    cidr.hostmask_ext => "0.0.0.255"

### Arguments:

- none

### Returns:

- String

    # File lib/cidr.rb, line 2074
    def hostmask_ext()
        return(NetAddr.ip_int_to_str(@hostmask, @version))
    end

netmask_ext() click to toggle source

### Synopsis

Provide IPv4 netmask in extended format (y.y.y.y).

    Example:
    cidr = NetAddr::CIDR.create('10.1.0.0/24')
    cidr.netmask_ext => "255.255.255.0"

### Arguments:

- none

### Returns:

- String

    # File lib/cidr.rb, line 2095
    def netmask_ext()
        return(NetAddr.ip_int_to_str(@netmask, 4))
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.