Project

ipcalc

0.0
No commit activity in last 3 years
No release in over 3 years
This gem provides classes that help IP manipulations.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Table of Contents

    • General description
    • Requirement
    • Building the gem from sources
    • Installing the gem
      • Installing from rubygems.org
      • Installing from local file system
    • Examples
    • Building the documentation
    • Author
    • Licence

General description

This gem contains classes that make IP manipulation easier.

  • Works with IPV4 and IPV6.
  • Arithmetic operations (+, -, +=, -=). For example, if IP="1.2.3.4", then IP+1="1.2.3.5".
  • Bitwise operations between IPs (|, &, ^).
  • Left and righ shifts (<<, >>).
  • Print IP in various formats:
    • The standard dotted notation. For example: 192.168.12.10
    • Decimal value. For example: 3232238602
    • Binary. For example: 11000000101010000000110000001010
    • Hexadecimal. For example: c0a80c0a
    • Pretty binary. For example: 11000000.10101000.00001100.00001010
    • Pretty hexadecimal. For example: c0.a8.0c.0a
  • Subnet discovery. What is the "/23" subnet that contains this IP?
  • Subnet testing. Is this IP included in this subnet?
  • IP comparaison (>, <, >=, <=, ==, !=, <=>). For example: "1.2.3.4" > "1.2.3.5" : FALSE
  • Manipulate IP like array. For examples, if IP="10.20.30.40":
    • IP[1] is 20.
    • IP[1] = 55, then IP="10.55.30.40"
  • Create IPs from integers of strings.

Requirement

Ruby 1.9.1 or greater (tested with Ruby 1.9.3)

Building the gem from sources

gem build ipcalc.gemspec

Installing the gem

Installing from rubygems.org

If you just want to use the gem, then this is the preferred installation procedure.

gem list -r ipcalc

gem install ipcalc

Installing from local file system

This procedure assumes that you have downloaded the gem' sources from GutHub. If you just need to use the gem, you should install the gem from "Rubygems.org" (see next section).

You need to build the gem.

gem build ipcalc.gemspec

Then you can install the gem. Please note that we assume that the gem's version is 1.0.0.

gem install ipcalc-1.0.0.gem

Examples

See the example file: https://github.com/denis-beurive/ipcalc/tree/master/examples

Building the documentation

Using Rdoc:

rdoc lib/ipcalc/*.rb

Or, you can call rake:

rake rdoc

Author

Denis BEURIVE (http://beurive.com/)

Licence

GPL