Class: Attractor::Value
- Inherits:
-
Object
- Object
- Attractor::Value
- Defined in:
- lib/attractor/value.rb
Overview
holds a churn/complexity value
Instance Attribute Summary collapse
-
#churn ⇒ Object
readonly
Returns the value of attribute churn.
-
#complexity ⇒ Object
readonly
Returns the value of attribute complexity.
-
#details ⇒ Object
readonly
Returns the value of attribute details.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#history ⇒ Object
readonly
Returns the value of attribute history.
Instance Method Summary collapse
- #current_commit ⇒ Object
-
#initialize(file_path: "", churn: 1, complexity: 0, details: [], history: []) ⇒ Value
constructor
A new instance of Value.
- #score ⇒ Object
- #to_h ⇒ Object
- #to_json(_opt) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(file_path: "", churn: 1, complexity: 0, details: [], history: []) ⇒ Value
Returns a new instance of Value.
10 11 12 13 14 15 16 |
# File 'lib/attractor/value.rb', line 10 def initialize(file_path: "", churn: 1, complexity: 0, details: [], history: []) @file_path = file_path @churn = churn @complexity = complexity @details = details @history = history end |
Instance Attribute Details
#churn ⇒ Object (readonly)
Returns the value of attribute churn.
8 9 10 |
# File 'lib/attractor/value.rb', line 8 def churn @churn end |
#complexity ⇒ Object (readonly)
Returns the value of attribute complexity.
8 9 10 |
# File 'lib/attractor/value.rb', line 8 def complexity @complexity end |
#details ⇒ Object (readonly)
Returns the value of attribute details.
8 9 10 |
# File 'lib/attractor/value.rb', line 8 def details @details end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
8 9 10 |
# File 'lib/attractor/value.rb', line 8 def file_path @file_path end |
#history ⇒ Object (readonly)
Returns the value of attribute history.
8 9 10 |
# File 'lib/attractor/value.rb', line 8 def history @history end |
Instance Method Details
#current_commit ⇒ Object
18 19 20 |
# File 'lib/attractor/value.rb', line 18 def current_commit history&.first&.first end |
#score ⇒ Object
22 23 24 |
# File 'lib/attractor/value.rb', line 22 def score @complexity * @churn end |
#to_h ⇒ Object
30 31 32 |
# File 'lib/attractor/value.rb', line 30 def to_h {file_path: file_path, x: churn, y: complexity, details: details, history: history} end |
#to_json(_opt) ⇒ Object
34 35 36 |
# File 'lib/attractor/value.rb', line 34 def to_json(_opt) to_h.to_json end |
#to_s ⇒ Object
26 27 28 |
# File 'lib/attractor/value.rb', line 26 def to_s format("%-64s%8.1f%8i", @file_path, @complexity, @churn) end |