Class: Link
- Inherits:
-
Object
- Object
- Link
- Defined in:
- lib/link.rb
Instance Attribute Summary collapse
-
#node1 ⇒ Object
Returns the value of attribute node1.
-
#node2 ⇒ Object
Returns the value of attribute node2.
Instance Method Summary collapse
- #display ⇒ Object
- #hide ⇒ Object
-
#initialize(n1, n2) ⇒ Link
constructor
A new instance of Link.
- #point?(node) ⇒ Boolean
- #remove_link ⇒ Object
- #show ⇒ Object
- #update_status ⇒ Object
Constructor Details
#initialize(n1, n2) ⇒ Link
Returns a new instance of Link.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/link.rb', line 6 def initialize(n1, n2) #true for up, false for down @state=true @name=nil @speed=nil @node1=n1 @node2=n2 $links.push(self) @node1.add_link(self) @node2.add_link(self) @view=LinkView.new(n1.map, self, [@node1.status, @node2.status].max) end |
Instance Attribute Details
#node1 ⇒ Object
Returns the value of attribute node1.
4 5 6 |
# File 'lib/link.rb', line 4 def node1 @node1 end |
#node2 ⇒ Object
Returns the value of attribute node2.
4 5 6 |
# File 'lib/link.rb', line 4 def node2 @node2 end |
Instance Method Details
#display ⇒ Object
34 35 36 |
# File 'lib/link.rb', line 34 def display() @view.display() end |
#hide ⇒ Object
30 31 32 |
# File 'lib/link.rb', line 30 def hide() @view.hide() end |
#point?(node) ⇒ Boolean
19 20 21 22 23 24 |
# File 'lib/link.rb', line 19 def point?(node) if (node==@node1) || (node==@node2) return true end return false end |
#remove_link ⇒ Object
38 39 40 |
# File 'lib/link.rb', line 38 def remove_link() @view.remove_link() end |
#show ⇒ Object
26 27 28 |
# File 'lib/link.rb', line 26 def show() @view.show() end |
#update_status ⇒ Object
42 43 44 |
# File 'lib/link.rb', line 42 def update_status() @view.update_status([@node1.status, @node2.status].max) end |