Class: Sarif::Tool
- Inherits:
-
Object
- Object
- Sarif::Tool
- Defined in:
- lib/sarif/tool.rb
Overview
The analysis tool that was run.
Instance Attribute Summary collapse
-
#driver ⇒ Object
Returns the value of attribute driver.
-
#extensions ⇒ Object
Returns the value of attribute extensions.
-
#properties ⇒ Object
Returns the value of attribute properties.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(driver:, extensions: [], properties: nil) ⇒ Tool
constructor
A new instance of Tool.
- #to_h ⇒ Object
- #to_json(pretty: false) ⇒ Object
Constructor Details
#initialize(driver:, extensions: [], properties: nil) ⇒ Tool
Returns a new instance of Tool.
8 9 10 11 12 |
# File 'lib/sarif/tool.rb', line 8 def initialize(driver:, extensions: [], properties: nil) @driver = driver @extensions = extensions @properties = properties end |
Instance Attribute Details
#driver ⇒ Object
Returns the value of attribute driver.
6 7 8 |
# File 'lib/sarif/tool.rb', line 6 def driver @driver end |
#extensions ⇒ Object
Returns the value of attribute extensions.
6 7 8 |
# File 'lib/sarif/tool.rb', line 6 def extensions @extensions end |
#properties ⇒ Object
Returns the value of attribute properties.
6 7 8 |
# File 'lib/sarif/tool.rb', line 6 def properties @properties end |
Class Method Details
.from_hash(h) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/sarif/tool.rb', line 26 def self.from_hash(h) return nil if h.nil? new( driver: ToolComponent.from_hash(h["driver"]), extensions: h["extensions"]&.map { |v| ToolComponent.from_hash(v) } || [], properties: h["properties"] ) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
35 36 37 38 |
# File 'lib/sarif/tool.rb', line 35 def ==(other) return false unless other.is_a?(Tool) @driver == other.driver && @extensions == other.extensions && @properties == other.properties end |
#hash ⇒ Object
42 43 44 |
# File 'lib/sarif/tool.rb', line 42 def hash [@driver, @extensions, @properties].hash end |
#to_h ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/sarif/tool.rb', line 14 def to_h h = {} h["driver"] = @driver&.to_h h["extensions"] = @extensions&.map(&:to_h) if @extensions&.any? h["properties"] = @properties unless @properties.nil? h end |
#to_json(pretty: false) ⇒ Object
22 23 24 |
# File 'lib/sarif/tool.rb', line 22 def to_json(pretty: false) pretty ? JSON.pretty_generate(to_h) : JSON.generate(to_h) end |