Class: IPAddress::Prefix
- Inherits:
-
Object
- Object
- IPAddress::Prefix
- Includes:
- Comparable
- Defined in:
- lib/ipaddress/prefix.rb
Overview
NAME
IPAddress::Prefix
SYNOPSIS
Parent class for Prefix32 and Prefix128
DESCRIPTION
IPAddresS::Prefix is the parent class for IPAddress::Prefix32 and IPAddress::Prefix128, defining some modules in common for both the subclasses.
IPAddress::Prefix shouldn’t be accesses directly, unless for particular needs.
Instance Attribute Summary collapse
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
Instance Method Summary collapse
- #<=>(oth) ⇒ Object
-
#initialize(num) ⇒ Prefix
constructor
A new instance of Prefix.
- #to_i ⇒ Object
- #to_s ⇒ Object (also: #inspect)
Constructor Details
#initialize(num) ⇒ Prefix
Returns a new instance of Prefix.
27 28 29 |
# File 'lib/ipaddress/prefix.rb', line 27 def initialize(num) @prefix = num.to_i end |
Instance Attribute Details
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
25 26 27 |
# File 'lib/ipaddress/prefix.rb', line 25 def prefix @prefix end |
Instance Method Details
#<=>(oth) ⇒ Object
40 41 42 |
# File 'lib/ipaddress/prefix.rb', line 40 def <=>(oth) @prefix <=> oth.to_i end |
#to_i ⇒ Object
36 37 38 |
# File 'lib/ipaddress/prefix.rb', line 36 def to_i @prefix end |
#to_s ⇒ Object Also known as: inspect
31 32 33 |
# File 'lib/ipaddress/prefix.rb', line 31 def to_s "#@prefix" end |