Class: Sarif::Suppression

Inherits:
Object
  • Object
show all
Defined in:
lib/sarif/suppression.rb

Overview

A suppression that is relevant to a result.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(guid: nil, kind:, status: nil, justification: nil, location: nil, properties: nil) ⇒ Suppression

Returns a new instance of Suppression.



8
9
10
11
12
13
14
15
# File 'lib/sarif/suppression.rb', line 8

def initialize(guid: nil, kind:, status: nil, justification: nil, location: nil, properties: nil)
  @guid = guid
  @kind = kind
  @status = status
  @justification = justification
  @location = location
  @properties = properties
end

Instance Attribute Details

#guidObject

Returns the value of attribute guid.



6
7
8
# File 'lib/sarif/suppression.rb', line 6

def guid
  @guid
end

#justificationObject

Returns the value of attribute justification.



6
7
8
# File 'lib/sarif/suppression.rb', line 6

def justification
  @justification
end

#kindObject

Returns the value of attribute kind.



6
7
8
# File 'lib/sarif/suppression.rb', line 6

def kind
  @kind
end

#locationObject

Returns the value of attribute location.



6
7
8
# File 'lib/sarif/suppression.rb', line 6

def location
  @location
end

#propertiesObject

Returns the value of attribute properties.



6
7
8
# File 'lib/sarif/suppression.rb', line 6

def properties
  @properties
end

#statusObject

Returns the value of attribute status.



6
7
8
# File 'lib/sarif/suppression.rb', line 6

def status
  @status
end

Class Method Details

.from_hash(h) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/sarif/suppression.rb', line 32

def self.from_hash(h)
  return nil if h.nil?
  new(
    guid: h["guid"],
    kind: h["kind"],
    status: h["status"],
    justification: h["justification"],
    location: Location.from_hash(h["location"]),
    properties: h["properties"]
  )
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



44
45
46
47
# File 'lib/sarif/suppression.rb', line 44

def ==(other)
  return false unless other.is_a?(Suppression)
  @guid == other.guid && @kind == other.kind && @status == other.status && @justification == other.justification && @location == other.location && @properties == other.properties
end

#hashObject



51
52
53
# File 'lib/sarif/suppression.rb', line 51

def hash
  [@guid, @kind, @status, @justification, @location, @properties].hash
end

#to_hObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/sarif/suppression.rb', line 17

def to_h
  h = {}
  h["guid"] = @guid unless @guid.nil?
  h["kind"] = @kind&.to_s
  h["status"] = @status&.to_s unless @status.nil?
  h["justification"] = @justification unless @justification.nil?
  h["location"] = @location&.to_h unless @location.nil?
  h["properties"] = @properties unless @properties.nil?
  h
end

#to_json(pretty: false) ⇒ Object



28
29
30
# File 'lib/sarif/suppression.rb', line 28

def to_json(pretty: false)
  pretty ? JSON.pretty_generate(to_h) : JSON.generate(to_h)
end