class IPAddress::Prefix
NAME¶ ↑
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.
Attributes
Public Class Methods
Source
# File lib/ipaddress/prefix.rb, line 30 def initialize(num) @prefix = num.to_i end
Creates a new general prefix
Public Instance Methods
Source
# File lib/ipaddress/prefix.rb, line 60 def +(oth) if oth.is_a? Integer self.prefix + oth else self.prefix + oth.prefix end end
Sums two prefixes or a prefix to a number, returns a Integer
Source
# File lib/ipaddress/prefix.rb, line 73 def -(oth) if oth.is_a? Integer self.prefix - oth else (self.prefix - oth.prefix).abs end end
Returns the difference between two prefixes, or a prefix and a number, as a Integer
Source
# File lib/ipaddress/prefix.rb, line 52 def <=>(oth) @prefix <=> oth.to_i end
Compare the prefix