Class: RuleDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/cfn-nag/rule_definition.rb

Direct Known Subclasses

Violation

Constant Summary collapse

WARNING =
'WARN'
FAILING_VIOLATION =
'FAIL'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, type:, message:) ⇒ RuleDefinition

Returns a new instance of RuleDefinition.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/cfn-nag/rule_definition.rb', line 9

def initialize(id:,
               type:,
               message:)
  @id = id
  @type = type
  @message = message

  [@id, @type, @message].each do |required|
    raise 'No parameters to Violation constructor can be nil' if required.nil?
  end
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/cfn-nag/rule_definition.rb', line 7

def id
  @id
end

#messageObject (readonly)

Returns the value of attribute message.



7
8
9
# File 'lib/cfn-nag/rule_definition.rb', line 7

def message
  @message
end

#typeObject (readonly)

Returns the value of attribute type.



7
8
9
# File 'lib/cfn-nag/rule_definition.rb', line 7

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object



33
34
35
# File 'lib/cfn-nag/rule_definition.rb', line 33

def ==(other)
  other.class == self.class && other.to_h == to_h
end

#to_hObject



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_sObject



21
22
23
# File 'lib/cfn-nag/rule_definition.rb', line 21

def to_s
  "#{@id} #{@type} #{@message}"
end