Class: Sarif::ArtifactLocation

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

Overview

Specifies the location of an artifact.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri: nil, uri_base_id: nil, index: -1,, description: nil, properties: nil) ⇒ ArtifactLocation

Returns a new instance of ArtifactLocation.



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

def initialize(uri: nil, uri_base_id: nil, index: -1, description: nil, properties: nil)
  @uri = uri
  @uri_base_id = uri_base_id
  @index = index
  @description = description
  @properties = properties
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



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

def description
  @description
end

#indexObject

Returns the value of attribute index.



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

def index
  @index
end

#propertiesObject

Returns the value of attribute properties.



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

def properties
  @properties
end

#uriObject

Returns the value of attribute uri.



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

def uri
  @uri
end

#uri_base_idObject

Returns the value of attribute uri_base_id.



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

def uri_base_id
  @uri_base_id
end

Class Method Details

.from_hash(h) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'lib/sarif/artifact_location.rb', line 30

def self.from_hash(h)
  return nil if h.nil?
  new(
    uri: h["uri"],
    uri_base_id: h["uriBaseId"],
    index: h["index"] || -1,
    description: Message.from_hash(h["description"]),
    properties: h["properties"]
  )
end

Instance Method Details

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



41
42
43
44
# File 'lib/sarif/artifact_location.rb', line 41

def ==(other)
  return false unless other.is_a?(ArtifactLocation)
  @uri == other.uri && @uri_base_id == other.uri_base_id && @index == other.index && @description == other.description && @properties == other.properties
end

#hashObject



48
49
50
# File 'lib/sarif/artifact_location.rb', line 48

def hash
  [@uri, @uri_base_id, @index, @description, @properties].hash
end

#to_hObject



16
17
18
19
20
21
22
23
24
# File 'lib/sarif/artifact_location.rb', line 16

def to_h
  h = {}
  h["uri"] = @uri unless @uri.nil?
  h["uriBaseId"] = @uri_base_id unless @uri_base_id.nil?
  h["index"] = @index if @index && @index != -1
  h["description"] = @description&.to_h unless @description.nil?
  h["properties"] = @properties unless @properties.nil?
  h
end

#to_json(pretty: false) ⇒ Object



26
27
28
# File 'lib/sarif/artifact_location.rb', line 26

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