Method: IPAddress::IPv4#bits
- Defined in:
- lib/ipaddress/ipv4.rb
#bits ⇒ Object
Returns the address portion of an IP in binary format, as a string containing a sequence of 0 and 1
ip = IPAddress("127.0.0.1")
ip.bits
#=> "01111111000000000000000000000001"
314 315 316 |
# File 'lib/ipaddress/ipv4.rb', line 314 def bits data.unpack("B*").first end |