Feature #1275


IPAddr unnecessarily destroys information on creation

Added by chrylis (Christopher Smith) about 13 years ago. Updated over 10 years ago.

Target version:


The IPAddr class internally stores both a complete IP address and a network mask. For many applications, client code needs to be able to track an interface's IP address (say, and its netmask (/24), and in IPv6, both the 128-bit identifier and the netmask are generally considered part of the address.

The current implementation of IPAddr immediately clears all masked bits, making it impossible to store information like ""; instead, the class stores only the network address of

Since it is always possible to mask off bits later, IPAddr should internally store the entire address alongside the netmask and provide the masked address on request (as already provided in #mask). I suggest adding an option "mask_host_part=true" to initialize and changing the check condition at 483 to "if prefixlen and mask_host_part" (to keep from breaking current code).

Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #1905: How about IPAddr#<=> to take care of mask_addr?Rejectedknu (Akinori MUSHA)08/07/2009Actions
Actions #1

Updated by yugui (Yuki Sonoda) almost 13 years ago

Patch is welcome.

Actions #2

Updated by ujihisa (Tatsuhiro Ujihisa) over 12 years ago

  • Status changed from Open to Assigned
  • Assignee set to knu (Akinori MUSHA)



Actions #3

Updated by znz (Kazuhiro NISHIYAMA) about 12 years ago

  • Category changed from core to lib
  • Target version set to 2.0.0



Updated by mame (Yusuke Endoh) over 10 years ago

  • Status changed from Assigned to Rejected

I'm rejecting this feature ticket because no progress has been
made for a long time. See [ruby-core:42391].

I'm not sure if this use case is valid for IPAddr library.
But if you still want the feature seriously, it might be good
to start with creating a patch, as Yugui said.

Yusuke Endoh


Also available in: Atom PDF