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"
316 317 318 |
# File 'lib/ipaddress/ipv4.rb', line 316 def bits data.unpack("B*").first end |