Class: SvgConform::QualityMetrics::ComplexityMetrics
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- SvgConform::QualityMetrics::ComplexityMetrics
- Defined in:
- lib/svg_conform/quality_metrics/complexity_metrics.rb
Overview
Immutable value object representing SVG complexity metrics.
Instance Method Summary collapse
-
#==(other) ⇒ Object
(also: #eql?)
Value equality.
-
#complexity_level ⇒ Object
Complexity level descriptions.
- #hash ⇒ Object
-
#high? ⇒ Boolean
True if complexity is high (7+).
-
#initialize(**args) ⇒ ComplexityMetrics
constructor
A new instance of ComplexityMetrics.
Constructor Details
#initialize(**args) ⇒ ComplexityMetrics
Returns a new instance of ComplexityMetrics.
24 25 26 27 |
# File 'lib/svg_conform/quality_metrics/complexity_metrics.rb', line 24 def initialize(**args) super(args) freeze end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
Value equality
30 31 32 33 34 35 |
# File 'lib/svg_conform/quality_metrics/complexity_metrics.rb', line 30 def ==(other) other.is_a?(ComplexityMetrics) && index == other.index && element_count == other.element_count && max_depth == other.max_depth end |
#complexity_level ⇒ Object
Complexity level descriptions
43 44 45 46 47 48 49 50 51 |
# File 'lib/svg_conform/quality_metrics/complexity_metrics.rb', line 43 def complexity_level case index when 1.0..2.9 then :simple when 3.0..4.9 then :moderate when 5.0..6.9 then :complex when 7.0..8.9 then :very_complex else :extremely_complex end end |
#hash ⇒ Object
38 39 40 |
# File 'lib/svg_conform/quality_metrics/complexity_metrics.rb', line 38 def hash [index, element_count, max_depth].hash end |
#high? ⇒ Boolean
Returns true if complexity is high (7+).
54 55 56 |
# File 'lib/svg_conform/quality_metrics/complexity_metrics.rb', line 54 def high? index >= 7.0 end |