Class: Metrics
- Inherits:
-
Object
show all
- Defined in:
- lib/compose_compiler_metrics/metrics.rb
Defined Under Namespace
Classes: Loader
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(hash) ⇒ Metrics
Returns a new instance of Metrics.
8
9
10
|
# File 'lib/compose_compiler_metrics/metrics.rb', line 8
def initialize(hash)
@hash = hash
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name) ⇒ Object
34
35
36
37
38
39
40
41
|
# File 'lib/compose_compiler_metrics/metrics.rb', line 34
def method_missing(method_name)
return hash[method_name.to_s] if hash.key?(method_name.to_s)
key = convert_to_metrics_key(method_name)
return hash[key] if hash.key?(key)
super method_name
end
|
Instance Attribute Details
#hash ⇒ Object
Returns the value of attribute hash.
6
7
8
|
# File 'lib/compose_compiler_metrics/metrics.rb', line 6
def hash
@hash
end
|
Class Method Details
.load(path) ⇒ Object
43
44
45
|
# File 'lib/compose_compiler_metrics/metrics.rb', line 43
def self.load(path)
Loader.new(path).load
end
|
Instance Method Details
#==(other) ⇒ Object
47
48
49
|
# File 'lib/compose_compiler_metrics/metrics.rb', line 47
def ==(other)
hash == other.hash
end
|
#grouped_metrics ⇒ Object
20
21
22
23
24
|
# File 'lib/compose_compiler_metrics/metrics.rb', line 20
def grouped_metrics
hash.
group_by { |k, _| grouping_key(k) }.
transform_values { |array| Metrics.new(array.to_h) }
end
|
#grouping_keys ⇒ Object
16
17
18
|
# File 'lib/compose_compiler_metrics/metrics.rb', line 16
def grouping_keys
keys.map { |key| grouping_key(key) }.uniq
end
|
#keys ⇒ Object
12
13
14
|
# File 'lib/compose_compiler_metrics/metrics.rb', line 12
def keys
to_h.keys
end
|
#respond_to_missing?(method_name, include_private) ⇒ Boolean
30
31
32
|
# File 'lib/compose_compiler_metrics/metrics.rb', line 30
def respond_to_missing?(method_name, include_private)
hash.key?(method_name.to_s) || hash.key?(convert_to_metrics_key(method_name)) || super
end
|
#to_h ⇒ Object
26
27
28
|
# File 'lib/compose_compiler_metrics/metrics.rb', line 26
def to_h
hash
end
|