Class: RaptorIO::Socket::SwitchBoard::Route
- Inherits:
-
Object
- Object
- RaptorIO::Socket::SwitchBoard::Route
- Includes:
- Comparable
- Defined in:
- lib/raptor-io/socket/switch_board/route.rb
Overview
A logical switch board route.
Instance Attribute Summary collapse
-
#comm ⇒ Object
readonly
Returns the value of attribute comm.
-
#netmask ⇒ Object
readonly
Returns the value of attribute netmask.
-
#subnet ⇒ Object
readonly
Returns the value of attribute subnet.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
For comparison, sort according to netmask.
-
#==(other) ⇒ Object
For direct equality, make sure all the attributes are the same.
-
#initialize(subnet, netmask, comm) ⇒ Route
constructor
A new instance of Route.
Constructor Details
#initialize(subnet, netmask, comm) ⇒ Route
Returns a new instance of Route.
16 17 18 19 20 |
# File 'lib/raptor-io/socket/switch_board/route.rb', line 16 def initialize(subnet, netmask, comm) self.netmask = IPAddr.parse(netmask) self.subnet = IPAddr.parse(subnet).mask netmask.to_s self.comm = comm end |
Instance Attribute Details
#comm ⇒ Object
Returns the value of attribute comm.
39 40 41 |
# File 'lib/raptor-io/socket/switch_board/route.rb', line 39 def comm @comm end |
#netmask ⇒ Object
Returns the value of attribute netmask.
39 40 41 |
# File 'lib/raptor-io/socket/switch_board/route.rb', line 39 def netmask @netmask end |
#subnet ⇒ Object
Returns the value of attribute subnet.
39 40 41 |
# File 'lib/raptor-io/socket/switch_board/route.rb', line 39 def subnet @subnet end |
Instance Method Details
#<=>(other) ⇒ Object
For comparison, sort according to netmask.
This allows routes to be ordered by specificity
35 36 37 |
# File 'lib/raptor-io/socket/switch_board/route.rb', line 35 def <=>(other) netmask <=> other.netmask end |
#==(other) ⇒ Object
For direct equality, make sure all the attributes are the same
25 26 27 28 |
# File 'lib/raptor-io/socket/switch_board/route.rb', line 25 def ==(other) return false unless other.kind_of? RaptorIO::Socket::SwitchBoard::Route netmask == other.netmask && subnet == other.subnet && comm == other.comm end |