Class: Sarif::SpecialLocations

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

Overview

Defines locations of special significance to SARIF consumers.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(display_base: nil, properties: nil) ⇒ SpecialLocations

Returns a new instance of SpecialLocations.



8
9
10
11
# File 'lib/sarif/special_locations.rb', line 8

def initialize(display_base: nil, properties: nil)
  @display_base = display_base
  @properties = properties
end

Instance Attribute Details

#display_baseObject

Returns the value of attribute display_base.



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

def display_base
  @display_base
end

#propertiesObject

Returns the value of attribute properties.



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

def properties
  @properties
end

Class Method Details

.from_hash(h) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/sarif/special_locations.rb', line 24

def self.from_hash(h)
  return nil if h.nil?
  new(
    display_base: ArtifactLocation.from_hash(h["displayBase"]),
    properties: h["properties"]
  )
end

Instance Method Details

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



32
33
34
35
# File 'lib/sarif/special_locations.rb', line 32

def ==(other)
  return false unless other.is_a?(SpecialLocations)
  @display_base == other.display_base && @properties == other.properties
end

#hashObject



39
40
41
# File 'lib/sarif/special_locations.rb', line 39

def hash
  [@display_base, @properties].hash
end

#to_hObject



13
14
15
16
17
18
# File 'lib/sarif/special_locations.rb', line 13

def to_h
  h = {}
  h["displayBase"] = @display_base&.to_h unless @display_base.nil?
  h["properties"] = @properties unless @properties.nil?
  h
end

#to_json(pretty: false) ⇒ Object



20
21
22
# File 'lib/sarif/special_locations.rb', line 20

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