Class: MetricFu::MethodContainer
- Inherits:
-
Object
- Object
- MetricFu::MethodContainer
- Defined in:
- lib/metric_fu/metrics/flog/generator.rb
Instance Attribute Summary collapse
-
#methods ⇒ Object
readonly
Returns the value of attribute methods.
Instance Method Summary collapse
- #add_method(full_method_name, operators, score, path) ⇒ Object
- #add_path(path) ⇒ Object
- #highest_score ⇒ Object
-
#initialize(name, path) ⇒ MethodContainer
constructor
A new instance of MethodContainer.
- #to_h ⇒ Object
Constructor Details
#initialize(name, path) ⇒ MethodContainer
Returns a new instance of MethodContainer.
59 60 61 62 63 |
# File 'lib/metric_fu/metrics/flog/generator.rb', line 59 def initialize(name, path) @name = name add_path path @methods = {} end |
Instance Attribute Details
#methods ⇒ Object (readonly)
Returns the value of attribute methods.
57 58 59 |
# File 'lib/metric_fu/metrics/flog/generator.rb', line 57 def methods @methods end |
Instance Method Details
#add_method(full_method_name, operators, score, path) ⇒ Object
70 71 72 |
# File 'lib/metric_fu/metrics/flog/generator.rb', line 70 def add_method(full_method_name, operators, score, path) @methods[full_method_name] = { operators: operators, score: score, path: path } end |
#add_path(path) ⇒ Object
65 66 67 68 |
# File 'lib/metric_fu/metrics/flog/generator.rb', line 65 def add_path(path) return unless path @path ||= path.split(":").first end |
#highest_score ⇒ Object
83 84 85 |
# File 'lib/metric_fu/metrics/flog/generator.rb', line 83 def highest_score method_scores.max end |
#to_h ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/metric_fu/metrics/flog/generator.rb', line 74 def to_h { name: @name, path: @path || "", total_score: total_score, highest_score: highest_score, average_score: average_score, methods: @methods } end |