Class: IP::Address
- Inherits:
-
Object
- Object
- IP::Address
- Defined in:
- lib/ip/address.rb
Overview
IP::Address - base class for IP::Address::IPv4 and IP::Address::IPv6
Defined Under Namespace
Modules: Util Classes: IPv4, IPv6
Instance Attribute Summary collapse
-
#ip_address ⇒ Object
readonly
This original IP Address you passed it, returned as a string.
-
#octets ⇒ Object
readonly
This returns an Array of Integer which contains the octets of the IP, in descending order.
Instance Method Summary collapse
-
#[](num) ⇒ Object
(also: #octet)
Returns an octet given the proper index.
-
#pack ⇒ Object
Returns a 128-bit integer representing the address.
Instance Attribute Details
#ip_address ⇒ Object (readonly)
This original IP Address you passed it, returned as a string.
10 11 12 |
# File 'lib/ip/address.rb', line 10 def ip_address @ip_address end |
#octets ⇒ Object (readonly)
This returns an Array of Integer which contains the octets of the IP, in descending order.
15 16 17 |
# File 'lib/ip/address.rb', line 15 def octets @octets end |
Instance Method Details
#[](num) ⇒ Object Also known as: octet
Returns an octet given the proper index. The octets returned are Integer types.
21 22 23 24 25 26 |
# File 'lib/ip/address.rb', line 21 def [](num) if @octets[num].nil? raise IP::BoundaryException.new("Invalid octet") end return @octets[num] end |
#pack ⇒ Object
Returns a 128-bit integer representing the address.
36 37 38 |
# File 'lib/ip/address.rb', line 36 def pack fail "This method is abstract." end |