Class: Sarif::ExternalPropertyFileReference

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

Overview

Contains information that enables a SARIF consumer to locate the external property file that contains the value of an externalized property associated with the run.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(location: nil, guid: nil, item_count: -1,, properties: nil) ⇒ ExternalPropertyFileReference

Returns a new instance of ExternalPropertyFileReference.



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

def initialize(location: nil, guid: nil, item_count: -1, properties: nil)
  @location = location
  @guid = guid
  @item_count = item_count
  @properties = properties
end

Instance Attribute Details

#guidObject

Returns the value of attribute guid.



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

def guid
  @guid
end

#item_countObject

Returns the value of attribute item_count.



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

def item_count
  @item_count
end

#locationObject

Returns the value of attribute location.



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

def location
  @location
end

#propertiesObject

Returns the value of attribute properties.



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

def properties
  @properties
end

Class Method Details

.from_hash(h) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/sarif/external_property_file_reference.rb', line 28

def self.from_hash(h)
  return nil if h.nil?
  new(
    location: ArtifactLocation.from_hash(h["location"]),
    guid: h["guid"],
    item_count: h["itemCount"] || -1,
    properties: h["properties"]
  )
end

Instance Method Details

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



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

def ==(other)
  return false unless other.is_a?(ExternalPropertyFileReference)
  @location == other.location && @guid == other.guid && @item_count == other.item_count && @properties == other.properties
end

#hashObject



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

def hash
  [@location, @guid, @item_count, @properties].hash
end

#to_hObject



15
16
17
18
19
20
21
22
# File 'lib/sarif/external_property_file_reference.rb', line 15

def to_h
  h = {}
  h["location"] = @location&.to_h unless @location.nil?
  h["guid"] = @guid unless @guid.nil?
  h["itemCount"] = @item_count if @item_count && @item_count != -1
  h["properties"] = @properties unless @properties.nil?
  h
end

#to_json(pretty: false) ⇒ Object



24
25
26
# File 'lib/sarif/external_property_file_reference.rb', line 24

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