Class: Spcap::IPAddress
- Inherits:
-
Object
- Object
- Spcap::IPAddress
- Defined in:
- lib/spcap/ipaddress.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Return true if two addresses are the same address.
-
#==(other) ⇒ Object
Return true if two addresses are the same address.
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#hostname ⇒ Object
Return host name correspond to this address.
-
#initialize(address) ⇒ IPAddress
constructor
A new instance of IPAddress.
-
#to_i ⇒ Object
Return the value of IP address as integer.
-
#to_num_s ⇒ Object
Return numerical string representation.
- #to_s ⇒ Object
Constructor Details
#initialize(address) ⇒ IPAddress
Returns a new instance of IPAddress.
5 6 7 |
# File 'lib/spcap/ipaddress.rb', line 5 def initialize(address) @address = address end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
3 4 5 |
# File 'lib/spcap/ipaddress.rb', line 3 def address @address end |
Instance Method Details
#<=>(other) ⇒ Object
Return true if two addresses are the same address.
10 11 12 |
# File 'lib/spcap/ipaddress.rb', line 10 def <=>(other) @address <=> other.address end |
#==(other) ⇒ Object
Return true if two addresses are the same address.
15 16 17 |
# File 'lib/spcap/ipaddress.rb', line 15 def ==(other) @address == other.address end |
#eql?(other) ⇒ Boolean
19 |
# File 'lib/spcap/ipaddress.rb', line 19 def eql?(other) ; self == other ; end |
#hash ⇒ Object
21 22 23 |
# File 'lib/spcap/ipaddress.rb', line 21 def hash @address.hash end |
#hostname ⇒ Object
Return host name correspond to this address.
26 27 28 29 |
# File 'lib/spcap/ipaddress.rb', line 26 def hostname # Not yet implemented to_num_s end |
#to_i ⇒ Object
Return the value of IP address as integer.
32 33 34 |
# File 'lib/spcap/ipaddress.rb', line 32 def to_i @address.unpackt("N").first end |
#to_num_s ⇒ Object
Return numerical string representation
38 39 40 |
# File 'lib/spcap/ipaddress.rb', line 38 def to_num_s @address.unpack("CCCC").join('.') end |
#to_s ⇒ Object
42 43 44 |
# File 'lib/spcap/ipaddress.rb', line 42 def to_s to_num_s end |