Class: Sarif::ReportingDescriptorReference

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

Overview

Information about how to locate a relevant reporting descriptor.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: nil, index: -1,, guid: nil, tool_component: nil, properties: nil) ⇒ ReportingDescriptorReference

Returns a new instance of ReportingDescriptorReference.



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

def initialize(id: nil, index: -1, guid: nil, tool_component: nil, properties: nil)
  @id = id
  @index = index
  @guid = guid
  @tool_component = tool_component
  @properties = properties
end

Instance Attribute Details

#guidObject

Returns the value of attribute guid.



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

def guid
  @guid
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#indexObject

Returns the value of attribute index.



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

def index
  @index
end

#propertiesObject

Returns the value of attribute properties.



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

def properties
  @properties
end

#tool_componentObject

Returns the value of attribute tool_component.



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

def tool_component
  @tool_component
end

Class Method Details

.from_hash(h) ⇒ Object



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

def self.from_hash(h)
  return nil if h.nil?
  new(
    id: h["id"],
    index: h["index"] || -1,
    guid: h["guid"],
    tool_component: ToolComponentReference.from_hash(h["toolComponent"]),
    properties: h["properties"]
  )
end

Instance Method Details

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



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

def ==(other)
  return false unless other.is_a?(ReportingDescriptorReference)
  @id == other.id && @index == other.index && @guid == other.guid && @tool_component == other.tool_component && @properties == other.properties
end

#hashObject



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

def hash
  [@id, @index, @guid, @tool_component, @properties].hash
end

#to_hObject



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

def to_h
  h = {}
  h["id"] = @id unless @id.nil?
  h["index"] = @index if @index && @index != -1
  h["guid"] = @guid unless @guid.nil?
  h["toolComponent"] = @tool_component&.to_h unless @tool_component.nil?
  h["properties"] = @properties unless @properties.nil?
  h
end

#to_json(pretty: false) ⇒ Object



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

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