class MetricFu::MethodContainer
Attributes
methods[R]
Public Class Methods
new(name, path)
click to toggle source
# File lib/metric_fu/metrics/flog/generator.rb, line 71 def initialize(name, path) @name = name add_path path @methods = {} end
Public Instance Methods
add_method(full_method_name, operators, score, path)
click to toggle source
# File lib/metric_fu/metrics/flog/generator.rb, line 82 def add_method(full_method_name, operators, score, path) @methods[full_method_name] = { operators: operators, score: score, path: path } end
add_path(path)
click to toggle source
# File lib/metric_fu/metrics/flog/generator.rb, line 77 def add_path(path) return unless path @path ||= path.split(":").first end
highest_score()
click to toggle source
# File lib/metric_fu/metrics/flog/generator.rb, line 95 def highest_score method_scores.max end
to_h()
click to toggle source
# File lib/metric_fu/metrics/flog/generator.rb, line 86 def to_h { name: @name, path: @path || "", total_score: total_score, highest_score: highest_score, average_score: average_score, methods: @methods } end
Private Instance Methods
average_score()
click to toggle source
# File lib/metric_fu/metrics/flog/generator.rb, line 109 def average_score total_score / method_scores.size.to_f end
method_scores()
click to toggle source
# File lib/metric_fu/metrics/flog/generator.rb, line 101 def method_scores @method_scores ||= @methods.values.map { |v| v[:score] } end
total_score()
click to toggle source
# File lib/metric_fu/metrics/flog/generator.rb, line 105 def total_score @total_score ||= method_scores.inject(0) { |sum, score| sum += score } end