Class: BaseNode
- Inherits:
-
Object
show all
- Defined in:
- lib/model/base_node.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(name, location, visibility, level) ⇒ BaseNode
Returns a new instance of BaseNode.
4
5
6
7
8
9
10
|
# File 'lib/model/base_node.rb', line 4
def initialize(name, location, visibility, level)
@name = name
@location = location
@visibility = visibility
@level = level
@tolerance = 35
end
|
Instance Attribute Details
#level ⇒ Object
Returns the value of attribute level.
2
3
4
|
# File 'lib/model/base_node.rb', line 2
def level
@level
end
|
#location ⇒ Object
Returns the value of attribute location.
2
3
4
|
# File 'lib/model/base_node.rb', line 2
def location
@location
end
|
#name ⇒ Object
Returns the value of attribute name.
2
3
4
|
# File 'lib/model/base_node.rb', line 2
def name
@name
end
|
Instance Method Details
#complexity_share ⇒ Object
28
29
30
31
|
# File 'lib/model/base_node.rb', line 28
def complexity_share
complexity > 0 ?
[0, ((complexity - @tolerance).to_f/complexity)].max : 0
end
|
#complexity_smells ⇒ Object
33
34
35
|
# File 'lib/model/base_node.rb', line 33
def complexity_smells
size * complexity_share
end
|
#file? ⇒ Boolean
16
17
18
|
# File 'lib/model/base_node.rb', line 16
def file?
false
end
|
#folder? ⇒ Boolean
12
13
14
|
# File 'lib/model/base_node.rb', line 12
def folder?
false
end
|
#function? ⇒ Boolean
20
21
22
|
# File 'lib/model/base_node.rb', line 20
def function?
false
end
|
#path ⇒ Object
24
25
26
|
# File 'lib/model/base_node.rb', line 24
def path
location != "" ? "#{location}/#{name}" : name
end
|
#private? ⇒ Boolean
37
38
39
|
# File 'lib/model/base_node.rb', line 37
def private?
@visibility == :private
end
|
#quality ⇒ Object
53
54
55
|
# File 'lib/model/base_node.rb', line 53
def quality
pot_smell > 0 ? 1.0-smells.to_f/pot_smell.to_f : 1
end
|
#smells ⇒ Object
49
50
51
|
# File 'lib/model/base_node.rb', line 49
def smells
complexity_smells + tangle_smells + node_smells
end
|
#tangle_share ⇒ Object
45
46
47
|
# File 'lib/model/base_node.rb', line 45
def tangle_share
0
end
|
#tangle_smells ⇒ Object
41
42
43
|
# File 'lib/model/base_node.rb', line 41
def tangle_smells
size * tangle_share
end
|