KO
|
EN
gitlite — search
Search
#python
#typescript
#javascript
#react
#tailwindcss
#django
#csharp
#redux
#cpp
#mongodb
#machine-learning
#frontend
ipaddr
★ 80
Open GitHub ↗
A class to manipulate an IP address
Download README (.md)
Explore Similar Repositories
pytorch-noreward-rl
:
pytorch implementation of Curiosity-driven Exploration by Self-supervised Prediction
auth0-spring-security-api
:
Spring Security integration with Auth0 to secure your API with JWTs
React-Redux-Enterprise
:
A React-Redux boilerplate for enterprise/large scaled web applications
coinwatch
:
Coinmarketcap console client to keep track of your crypto currency trades - are you winning or losing?
react-native-todo
:
Todo-List app using react-native SwipeView and redux.js with ES6 standards
// repository documentation
Was this content helpful?
★ 0
(0 ratings)
Select Rating:
★
★
★
★
★
Submit Feedback
Recent Feedback
×
Download README
Do you want to download the
README.md
file for
ipaddr
?
Download (.md)
# IPAddr IPAddr provides a set of methods to manipulate an IP address. Both IPv4 and IPv6 are supported. [](https://github.com/ruby/ipaddr/actions/workflows/test.yml) ## Installation This library is part of the standard ruby distribution as default gem and synchronized periodically, but you can explicitly depend on this gem with version constraints as necessary, like when you need a newer version than comes with older versions of ruby. For example, you can add this line to your application's Gemfile: ```ruby gem 'ipaddr', '~> 1.2' ``` And then execute: $ bundle Or install it yourself as: $ gem install ipaddr ## Usage ```ruby require 'ipaddr' ipaddr1 = IPAddr.new "3ffe:505:2::1" p ipaddr1 #=> #<IPAddr: IPv6:3ffe:0505:0002:0000:0000:0000:0000:0001/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff> p ipaddr1.to_s #=> "3ffe:505:2::1" ipaddr2 = ipaddr1.mask(48) #=> #<IPAddr: IPv6:3ffe:0505:0002:0000:0000:0000:0000:0000/ffff:ffff:ffff:0000:0000:0000:0000:0000> p ipaddr2.to_s #=> "3ffe:505:2::" ipaddr3 = IPAddr.new "192.168.2.0/24" p ipaddr3 #=> #<IPAddr: IPv4:192.168.2.0/255.255.255.0> ``` ## Alternative The [ipaddress](https://rubygems.org/gems/ipaddress) gem is a popular, extensive library for manipulating IP addresses with a layer of compatibility with `ipaddr`. If you need a richer set of features than `ipaddr` has, try this library instead. ## Development After checking out the repo, run `bundle install` to install dependencies. Then, run `rake test` to run the tests. To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). ## Contributing Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/ipaddr. ## License The gem is available as open source under the terms of the [2-Clause BSD License](https://opensource.org/licenses/BSD-2-Clause).