Class: NetSpace::Subnet
- Inherits:
-
Object
- Object
- NetSpace::Subnet
- Defined in:
- lib/netspace/subnet.rb
Overview
Class representing an IP subnet. At its core, it’s a base IP and a netmask, both converted to 32-bit integers for fast comparisons.
Instance Attribute Summary collapse
-
#bits ⇒ Object
Returns the value of attribute bits.
-
#ip ⇒ Object
Returns the value of attribute ip.
-
#ip32 ⇒ Object
Returns the value of attribute ip32.
-
#mask ⇒ Object
Returns the value of attribute mask.
-
#mask32 ⇒ Object
Returns the value of attribute mask32.
Instance Method Summary collapse
-
#in?(ip) ⇒ Boolean
Test if indicated IP address resides within the boundaries of the subnet.
-
#initialize(ip, bits) ⇒ Subnet
constructor
A new instance of Subnet.
-
#ips ⇒ Object
Return a list of all IPs (as strings) that are legitimately members of the subnet.
Constructor Details
Instance Attribute Details
#bits ⇒ Object
Returns the value of attribute bits.
10 11 12 |
# File 'lib/netspace/subnet.rb', line 10 def bits @bits end |
#ip ⇒ Object
Returns the value of attribute ip.
10 11 12 |
# File 'lib/netspace/subnet.rb', line 10 def ip @ip end |
#ip32 ⇒ Object
Returns the value of attribute ip32.
10 11 12 |
# File 'lib/netspace/subnet.rb', line 10 def ip32 @ip32 end |
#mask ⇒ Object
Returns the value of attribute mask.
10 11 12 |
# File 'lib/netspace/subnet.rb', line 10 def mask @mask end |
#mask32 ⇒ Object
Returns the value of attribute mask32.
10 11 12 |
# File 'lib/netspace/subnet.rb', line 10 def mask32 @mask32 end |