Class: Violation
- Inherits:
-
Object
- Object
- Violation
- Defined in:
- lib/violation.rb
Constant Summary collapse
- WARNING =
'WARN'
- FAILING_VIOLATION =
'FAIL'
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#logical_resource_ids ⇒ Object
readonly
Returns the value of attribute logical_resource_ids.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#violating_code ⇒ Object
readonly
Returns the value of attribute violating_code.
Instance Method Summary collapse
- #==(other_violation) ⇒ Object
-
#initialize(id:, type:, message:, logical_resource_ids: nil, violating_code: nil) ⇒ Violation
constructor
A new instance of Violation.
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(id:, type:, message:, logical_resource_ids: nil, violating_code: nil) ⇒ Violation
Returns a new instance of Violation.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/violation.rb', line 9 def initialize(id:, type:, message:, logical_resource_ids: nil, violating_code: nil) @id = id @type = type @message = @logical_resource_ids = logical_resource_ids @violating_code = violating_code fail if @type.nil? fail if @message.nil? end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/violation.rb', line 7 def id @id end |
#logical_resource_ids ⇒ Object (readonly)
Returns the value of attribute logical_resource_ids.
7 8 9 |
# File 'lib/violation.rb', line 7 def logical_resource_ids @logical_resource_ids end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
7 8 9 |
# File 'lib/violation.rb', line 7 def @message end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/violation.rb', line 7 def type @type end |
#violating_code ⇒ Object (readonly)
Returns the value of attribute violating_code.
7 8 9 |
# File 'lib/violation.rb', line 7 def violating_code @violating_code end |
Instance Method Details
#==(other_violation) ⇒ Object
38 39 40 |
# File 'lib/violation.rb', line 38 def ==(other_violation) other_violation.class == self.class && other_violation.to_h == to_h end |
#to_h ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/violation.rb', line 28 def to_h { id: @id, type: @type, message: @message, logical_resource_ids: @logical_resource_ids, violating_code: @violating_code } end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/violation.rb', line 24 def to_s puts "#{@id} #{@type} #{@message} #{@logical_resource_ids} #{@violating_code}" end |