Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/abates/ip_tools
This project adds a number of useful method to Ruby's IpAddr class. It also creates a validator that can validate strings in IPv4 or IPv6 format
https://github.com/abates/ip_tools
Last synced: about 7 hours ago
JSON representation
This project adds a number of useful method to Ruby's IpAddr class. It also creates a validator that can validate strings in IPv4 or IPv6 format
- Host: GitHub
- URL: https://github.com/abates/ip_tools
- Owner: abates
- License: mit
- Created: 2010-10-20T14:42:42.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2012-04-10T15:39:45.000Z (over 12 years ago)
- Last Synced: 2023-03-11T09:57:15.088Z (over 1 year ago)
- Language: Ruby
- Homepage:
- Size: 97.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- License: MIT-LICENSE
Awesome Lists containing this project
README
IpTools
=======IpTools is a Ruby on Rails plugin that provides some useful functionality to the IpAddr class that ships with Ruby.
This plugin creates methods that will return the netmask of an IpAddr object, as well as its prefix (used in CIDR notation), as well as methods to retrieve the inverse mask and broadcast. These methods simplify working with IpAddr objects, especially when binary arithmetic is required to find IPs within ranges, etc.
Example
=======require "ipaddr"
require "netmask_tools"ip = IPAddr.new("192.168.1.0/24", Socket::AF_INET)
print "#{ip.netmask}\n" # 255.255.255.0
print "#{ip.broadcast}\n" # 192.168.1.255
print "#{ip.prefix}\n" # 24Copyright (c) 2010 Andrew Bates, released under the MIT license