{"id":18728681,"url":"https://github.com/rubyonworld/ruby-ip","last_synced_at":"2026-04-29T15:36:38.327Z","repository":{"id":174008086,"uuid":"542162706","full_name":"RubyOnWorld/ruby-ip","owner":"RubyOnWorld","description":"This is a library for manipulating IP addresses.","archived":false,"fork":false,"pushed_at":"2022-09-28T01:06:15.000Z","size":63,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-19T20:32:28.664Z","etag":null,"topics":["address","ip","library","rails"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RubyOnWorld.png","metadata":{"files":{"readme":"README.rdoc","changelog":null,"contributing":null,"funding":null,"license":"COPYING.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-09-27T15:39:31.000Z","updated_at":"2022-09-28T03:58:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"e5e020d6-e60b-49e2-9e40-e278335c1079","html_url":"https://github.com/RubyOnWorld/ruby-ip","commit_stats":null,"previous_names":["rubyonworld/ruby-ip"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RubyOnWorld/ruby-ip","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyOnWorld%2Fruby-ip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyOnWorld%2Fruby-ip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyOnWorld%2Fruby-ip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyOnWorld%2Fruby-ip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RubyOnWorld","download_url":"https://codeload.github.com/RubyOnWorld/ruby-ip/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyOnWorld%2Fruby-ip/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32432163,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T13:34:34.882Z","status":"ssl_error","status_checked_at":"2026-04-29T13:34:29.830Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["address","ip","library","rails"],"created_at":"2024-11-07T14:23:39.202Z","updated_at":"2026-04-29T15:36:38.322Z","avatar_url":"https://github.com/RubyOnWorld.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"= ruby-ip library\n\nThis is a library for manipulating IP addresses.\n\n== Installation\n\nGem:: \u003ctt\u003egem install ruby-ip\u003c/tt\u003e\nSource:: \u003ctt\u003egit clone git://github.com/deploy2/ruby-ip.git\u003c/tt\u003e\nDocs:: http://deploy2.github.com/ruby-ip/\n\n== Feature overview\n\n* Create from string and to string\n\n    require 'ip'\n    ip = IP.new(\"192.0.2.53/24\")\n    ip.to_s       # \"192.0.2.53/24\"\n    ip.to_i       # 3221226037\n    ip.to_b       # 11000000000000000000001000110101\n    ip.to_hex     # \"c0000235\"\n    ip.to_addr    # \"192.0.2.53\"\n    ip.to_arpa    # \"53.2.0.192.in-addr.arpa.\"\n    ip.pfxlen     # 24\n\n* Qualify IP address with \"routing context\" (VRF)\n\n    ip = IP.new(\"192.0.2.53/24@cust1\")\n    ip.to_s       # \"192.0.2.53/24@cust1\"\n    ip.to_addrlen # \"192.0.2.53/24\"\n    ip.ctx        # \"cust1\"\n\n* Clean implementation of IP::V4 and IP::V6 as subclasses of IP\n\n    ip1 = IP.new(\"192.0.2.53/24\")       #\u003cIP::V4 192.0.2.53/24\u003e\n    ip2 = IP.new(\"2001:db8:be00::/48\")  #\u003cIP::V6 2001:db8:be00::/48\u003e\n    ip1.is_a?(IP::V4)                   # true\n\n* Create directly from integers or hex\n\n    ip = IP::V4.new(3221226037, 24, \"cust1\")\n    ip = IP::V4.new(\"c0000235\", 24, \"cust1\")\n\n* Netmask manipulation\n\n    ip = IP.new(\"192.0.2.53/24\")\n    ip.network         #\u003cIP::V4 192.0.2.0/24\u003e\n    ip.network(1)      #\u003cIP::V4 192.0.2.1/24\u003e\n    ip.broadcast       #\u003cIP::V4 192.0.2.255/24\u003e\n    ip.broadcast(-1)   #\u003cIP::V4 192.0.2.254/24\u003e\n    ip.mask            # 255\n    ip.size            # 256\n    ip.netmask.to_s    # \"255.255.255.0\"\n    ip.wildmask.to_s   # \"0.0.0.255\"\n\n* Address masking\n\n    ip = IP.new(\"192.0.2.53/24\")\n    ip.offset?         # true\n    ip.offset          # 53\n    ip.mask!\n    ip.to_s            # \"192.0.2.0/24\"\n    ip.offset?         # false\n\n* Simple IP arithmetic\n\n    ip = IP.new(\"192.0.2.53/24\")\n    ip + 4             #\u003cIP::V4 192.0.2.57/24\u003e\n    ip | 7             #\u003cIP::V4 192.0.2.55/24\u003e\n    ip ^ 7             #\u003cIP::V4 192.0.2.50/24\u003e\n    ~ip                #\u003cIP::V4 63.255.253.202/24\u003e\n\n* Advanced Subnet Operations\n    sn = IP.new('192.168.0.0/24')\n    ip = IP.new('192.168.0.48/32')\n    sn.split                    [#\u003cIP::V4 192.168.0.0/25\u003e, \n                                #\u003cIP::V4 192.168.0.128/25\u003e] (2 evenly divided subnets)\n    sn.divide_by_subnets(3)     [#\u003cIP::V4 192.168.0.0/26\u003e, \n                                #\u003cIP::V4 192.168.0.64/26\u003e, \n                                #\u003cIP::V4 192.168.0.128/26\u003e, \n                                #\u003cIP::V4 192.168.0.192/26\u003e] (4 evenly divided subnets)\n    #keep in mind this always takes into account a network and broadcast address\n    sn.divide_by_hosts(100)     [#\u003cIP::V4 192.168.0.0/25\u003e, \n                                #\u003cIP::V4 192.168.0.128/25\u003e] (128 hosts each)\n    ip = IP.new('192.168.0.48/32')\n    ip.is_in?(sn)\n    =\u003e true \n    \n\n* Convert to and from a compact Array representation\n\n    ip1 = IP.new(\"192.0.2.53/24@cust1\")\n    ip1.to_a     # [\"v4\", 3221226037, 24, \"cust1\"]\n\n    ip2 = IP.new([\"v4\", 3221226037, 24, \"cust1\"])\n    ip1 == ip2   # true\n\n* Hex array representation, useful when talking to languages which don't\n  have Bignum support\n\n    ip1 = IP.new(\"2001:db8:be00::/48@cust1\")\n    ip1.to_ah    # [\"v6\", \"20010db8be0000000000000000000000\", 48, \"cust1\"]\n\n    ip2 = IP.new([\"v6\", \"20010db8be0000000000000000000000\", 48, \"cust1\"])\n    ip1 == ip2   # true\n\n* Addresses are Comparable, sortable, and can be used as Hash keys\n\n== Why not IPAddr?\n\nRuby bundles an IPAddr class (ipaddr.rb). However there are a number of\nserious problems with this library.\n\n1. Given an IP address with a netmask or prefix (e.g. 192.0.2.0/24) it's\n   very hard to get access to the netmask part. It involves digging around\n   instance variables.\n\n2. It's impossible to deal with an off-base address with prefix, because\n   IPAddr forcibly masks it to the base. e.g. 192.0.2.53/24 is stored as\n   192.0.2.0/24\n\n3. IPAddr uses calls to the socket library to validate IP addresses, and\n   this can trigger spurious DNS lookups when given an invalid IP address.\n   ruby-ip does not depend on the socket library at all, unless you\n   require 'ip/socket' to have access to the Socket::AF_INET and\n   Socket::AF_INET6 constants.\n\n== Copying\n\nYou may use, distribute and modify this software under the same terms as\nruby itself (see LICENSE.txt and COPYING.txt)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyonworld%2Fruby-ip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubyonworld%2Fruby-ip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyonworld%2Fruby-ip/lists"}