Class: OSPFv2::Hello::Neighbors
Constant Summary collapse
Instance Attribute Summary collapse
-
#routers ⇒ Object
readonly
Returns the value of attribute routers.
Instance Method Summary collapse
- #+(id) ⇒ Object
- #-(id) ⇒ Object
- #[](val) ⇒ Object
- #encode ⇒ Object
- #has?(id) ⇒ Boolean
-
#initialize(arg = nil) ⇒ Neighbors
constructor
A new instance of Neighbors.
- #neighbors ⇒ Object (also: #ids)
- #to_s_ary ⇒ Object
Constructor Details
#initialize(arg = nil) ⇒ Neighbors
Returns a new instance of Neighbors.
197 198 199 200 |
# File 'lib/packet/hello.rb', line 197 def initialize(arg=nil) @set = Set.new [arg].compact.flatten.each { |x| self + x } end |
Instance Attribute Details
#routers ⇒ Object (readonly)
Returns the value of attribute routers.
196 197 198 |
# File 'lib/packet/hello.rb', line 196 def routers @routers end |
Instance Method Details
#+(id) ⇒ Object
201 202 203 |
# File 'lib/packet/hello.rb', line 201 def +(id) @set << neighbor(id) end |
#-(id) ⇒ Object
211 212 213 |
# File 'lib/packet/hello.rb', line 211 def -(id) @set.delete neighbor(id) end |
#[](val) ⇒ Object
217 218 219 |
# File 'lib/packet/hello.rb', line 217 def [](val) neighbors[val] end |
#encode ⇒ Object
214 215 216 |
# File 'lib/packet/hello.rb', line 214 def encode ids.pack('N*') end |
#has?(id) ⇒ Boolean
208 209 210 |
# File 'lib/packet/hello.rb', line 208 def has?(id) ids.include?(neighbor(id)) end |
#neighbors ⇒ Object Also known as: ids
204 205 206 |
# File 'lib/packet/hello.rb', line 204 def neighbors @set.collect.sort end |