net-ipaddress

Build Status Gem Version Dependency Status

Description

Utils for ipaddresses

Features

  • Usuful methods
  • Immutable
  • Now, supporting version4

Usage

Setup

require 'net/ipaddress'
include Net

Basic

ip1 = IPAddress('192.168.1.1/24')
ip2 = IPAddress('192.168.1.10/24')
ip3 = IPAddress('192.168.0.0/16')
ip1.segment? ip2 #=> true
ip2.segment? ip1 #=> true
ip1.segment? ip3 #=> false
ip1.cover? ip3   #=> false
ip3.cover? ip1   #=> true

IPAddr <-> Net::IPAddress

require 'net/ipaddress/ext/ipaddr'

IPAddr.new('192.168.1.1/24') == IPAddress('192.168.1.1/24').network #=> true

Requirements

Installation

$ gem install net-ipaddress

Link

License

The MIT X11 License
Copyright (c) 2012 Kenichi Kamiya
See MIT-LICENSE for further details.