Class: MetricFu::MethodContainer

Inherits:
Object
  • Object
show all
Defined in:
lib/metric_fu/metrics/flog/generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, path) ⇒ MethodContainer

Returns a new instance of MethodContainer.



71
72
73
74
75
# File 'lib/metric_fu/metrics/flog/generator.rb', line 71

def initialize(name, path)
  @name = name
  add_path path
  @methods = {}
end

Instance Attribute Details

#methodsObject (readonly)

Returns the value of attribute methods.



69
70
71
# File 'lib/metric_fu/metrics/flog/generator.rb', line 69

def methods
  @methods
end

Instance Method Details

#add_method(full_method_name, operators, score, path) ⇒ Object



82
83
84
# 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) ⇒ Object



77
78
79
80
# File 'lib/metric_fu/metrics/flog/generator.rb', line 77

def add_path(path)
  return unless path
  @path ||= path.split(":").first
end

#highest_scoreObject



95
96
97
# File 'lib/metric_fu/metrics/flog/generator.rb', line 95

def highest_score
  method_scores.max
end

#to_hObject



86
87
88
89
90
91
92
93
# 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