Class: CodePoetry::Method
- Inherits:
-
Object
- Object
- CodePoetry::Method
- Defined in:
- lib/code_poetry/method.rb
Instance Attribute Summary collapse
-
#complexity ⇒ Object
Returns the value of attribute complexity.
-
#duplication_count ⇒ Object
Returns the value of attribute duplication_count.
-
#first_line ⇒ Object
readonly
Returns the value of attribute first_line.
-
#last_line ⇒ Object
readonly
Returns the value of attribute last_line.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#node ⇒ Object
Returns the value of attribute node.
Instance Method Summary collapse
- #duplicated? ⇒ Boolean
- #increase_duplication_count ⇒ Object
-
#initialize(node, name, first_line, last_line, location) ⇒ Method
constructor
A new instance of Method.
- #pretty_location ⇒ Object
- #pretty_name ⇒ Object
- #smelly? ⇒ Boolean
Constructor Details
#initialize(node, name, first_line, last_line, location) ⇒ Method
Returns a new instance of Method.
6 7 8 9 10 11 12 13 14 |
# File 'lib/code_poetry/method.rb', line 6 def initialize(node, name, first_line, last_line, location) @node = node @name = name @first_line = first_line @last_line = last_line @complexity = 0 @duplication_count = 0 @location = location.sub './', '' end |
Instance Attribute Details
#complexity ⇒ Object
Returns the value of attribute complexity.
4 5 6 |
# File 'lib/code_poetry/method.rb', line 4 def complexity @complexity end |
#duplication_count ⇒ Object
Returns the value of attribute duplication_count.
4 5 6 |
# File 'lib/code_poetry/method.rb', line 4 def duplication_count @duplication_count end |
#first_line ⇒ Object (readonly)
Returns the value of attribute first_line.
3 4 5 |
# File 'lib/code_poetry/method.rb', line 3 def first_line @first_line end |
#last_line ⇒ Object (readonly)
Returns the value of attribute last_line.
3 4 5 |
# File 'lib/code_poetry/method.rb', line 3 def last_line @last_line end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/code_poetry/method.rb', line 3 def name @name end |
#node ⇒ Object
Returns the value of attribute node.
4 5 6 |
# File 'lib/code_poetry/method.rb', line 4 def node @node end |
Instance Method Details
#duplicated? ⇒ Boolean
20 21 22 |
# File 'lib/code_poetry/method.rb', line 20 def duplicated? @duplication_count > 0 end |
#increase_duplication_count ⇒ Object
33 34 35 |
# File 'lib/code_poetry/method.rb', line 33 def increase_duplication_count @duplication_count =+ 1 end |
#pretty_location ⇒ Object
29 30 31 |
# File 'lib/code_poetry/method.rb', line 29 def pretty_location "#{@location}:#{@first_line}..#{@last_line}" end |
#pretty_name ⇒ Object
24 25 26 27 |
# File 'lib/code_poetry/method.rb', line 24 def pretty_name symbol = @node == :def ? '.' : '#' "#{symbol}#{@name}" end |
#smelly? ⇒ Boolean
16 17 18 |
# File 'lib/code_poetry/method.rb', line 16 def smelly? @complexity > 25 end |