Class: Link

Inherits:
Object
  • Object
show all
Defined in:
lib/link.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#node1Object

Returns the value of attribute node1.



4
5
6
# File 'lib/link.rb', line 4

def node1
  @node1
end

#node2Object

Returns the value of attribute node2.



4
5
6
# File 'lib/link.rb', line 4

def node2
  @node2
end

Instance Method Details

#displayObject



34
35
36
# File 'lib/link.rb', line 34

def display()
	@view.display()
end

#hideObject



30
31
32
# File 'lib/link.rb', line 30

def hide()
	@view.hide()
end

#point?(node) ⇒ Boolean

Returns:

  • (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


38
39
40
# File 'lib/link.rb', line 38

def remove_link()
	@view.remove_link()
end

#showObject



26
27
28
# File 'lib/link.rb', line 26

def show()
	@view.show()
end

#update_statusObject



42
43
44
# File 'lib/link.rb', line 42

def update_status()
  @view.update_status([@node1.status, @node2.status].max)
end