Class: Package::Audit::Risk
- Inherits:
-
Object
- Object
- Package::Audit::Risk
- Includes:
- Comparable
- Defined in:
- lib/package/audit/models/risk.rb
Instance Attribute Summary collapse
-
#explanation ⇒ Object
readonly
Returns the value of attribute explanation.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity.
-
#initialize(type, explanation = nil) ⇒ Risk
constructor
A new instance of Risk.
Constructor Details
#initialize(type, explanation = nil) ⇒ Risk
Returns a new instance of Risk.
8 9 10 11 |
# File 'lib/package/audit/models/risk.rb', line 8 def initialize(type, explanation = nil) @type = type @explanation = explanation end |
Instance Attribute Details
#explanation ⇒ Object (readonly)
Returns the value of attribute explanation.
6 7 8 |
# File 'lib/package/audit/models/risk.rb', line 6 def explanation @explanation end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/package/audit/models/risk.rb', line 6 def type @type end |
Instance Method Details
#<=>(other) ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/package/audit/models/risk.rb', line 13 def <=>(other) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity if @type == other.type 0 elsif (@type == Enum::RiskType::HIGH && [Enum::RiskType::MEDIUM, Enum::RiskType::LOW, Enum::RiskType::NONE].include?(other.type)) || (@type == Enum::RiskType::MEDIUM && [Enum::RiskType::LOW, Enum::RiskType::NONE].include?(other.type)) || (@type == Enum::RiskType::LOW && [Enum::RiskType::NONE].include?(other.type)) 1 else -1 end end |