Class: RuleDefinition
- Inherits:
-
Object
- Object
- RuleDefinition
- Defined in:
- lib/cfn-nag/rule_definition.rb
Direct Known Subclasses
Constant Summary collapse
- WARNING =
'WARN'
- FAILING_VIOLATION =
'FAIL'
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other_violation) ⇒ Object
-
#initialize(id:, type:, message:) ⇒ RuleDefinition
constructor
A new instance of RuleDefinition.
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(id:, type:, message:) ⇒ RuleDefinition
Returns a new instance of RuleDefinition.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/cfn-nag/rule_definition.rb', line 7 def initialize(id:, type:, message:) @id = id @type = type @message = [@id, @type, @message].each do |required| if required.nil? raise 'No parameters to Violation constructor can be nil' end end end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/cfn-nag/rule_definition.rb', line 5 def id @id end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
5 6 7 |
# File 'lib/cfn-nag/rule_definition.rb', line 5 def @message end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/cfn-nag/rule_definition.rb', line 5 def type @type end |
Instance Method Details
#==(other_violation) ⇒ Object
33 34 35 |
# File 'lib/cfn-nag/rule_definition.rb', line 33 def ==(other_violation) other_violation.class == self.class && other_violation.to_h == to_h end |
#to_h ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/cfn-nag/rule_definition.rb', line 25 def to_h { id: @id, type: @type, message: @message } end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/cfn-nag/rule_definition.rb', line 21 def to_s "#{@id} #{@type} #{@message}" end |