Class: Sarif::ToolComponentReference
- Inherits:
-
Object
- Object
- Sarif::ToolComponentReference
- Defined in:
- lib/sarif/tool_component_reference.rb
Overview
Identifies a particular toolComponent object, either the driver or an extension.
Instance Attribute Summary collapse
-
#guid ⇒ Object
Returns the value of attribute guid.
-
#index ⇒ Object
Returns the value of attribute index.
-
#name ⇒ Object
Returns the value of attribute name.
-
#properties ⇒ Object
Returns the value of attribute properties.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(name: nil, index: -1,, guid: nil, properties: nil) ⇒ ToolComponentReference
constructor
A new instance of ToolComponentReference.
- #to_h ⇒ Object
- #to_json(pretty: false) ⇒ Object
Constructor Details
#initialize(name: nil, index: -1,, guid: nil, properties: nil) ⇒ ToolComponentReference
Returns a new instance of ToolComponentReference.
8 9 10 11 12 13 |
# File 'lib/sarif/tool_component_reference.rb', line 8 def initialize(name: nil, index: -1, guid: nil, properties: nil) @name = name @index = index @guid = guid @properties = properties end |
Instance Attribute Details
#guid ⇒ Object
Returns the value of attribute guid.
6 7 8 |
# File 'lib/sarif/tool_component_reference.rb', line 6 def guid @guid end |
#index ⇒ Object
Returns the value of attribute index.
6 7 8 |
# File 'lib/sarif/tool_component_reference.rb', line 6 def index @index end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/sarif/tool_component_reference.rb', line 6 def name @name end |
#properties ⇒ Object
Returns the value of attribute properties.
6 7 8 |
# File 'lib/sarif/tool_component_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/tool_component_reference.rb', line 28 def self.from_hash(h) return nil if h.nil? new( name: h["name"], index: h["index"] || -1, guid: h["guid"], properties: h["properties"] ) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
38 39 40 41 |
# File 'lib/sarif/tool_component_reference.rb', line 38 def ==(other) return false unless other.is_a?(ToolComponentReference) @name == other.name && @index == other.index && @guid == other.guid && @properties == other.properties end |
#hash ⇒ Object
45 46 47 |
# File 'lib/sarif/tool_component_reference.rb', line 45 def hash [@name, @index, @guid, @properties].hash end |
#to_h ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/sarif/tool_component_reference.rb', line 15 def to_h h = {} h["name"] = @name unless @name.nil? h["index"] = @index if @index && @index != -1 h["guid"] = @guid unless @guid.nil? h["properties"] = @properties unless @properties.nil? h end |
#to_json(pretty: false) ⇒ Object
24 25 26 |
# File 'lib/sarif/tool_component_reference.rb', line 24 def to_json(pretty: false) pretty ? JSON.pretty_generate(to_h) : JSON.generate(to_h) end |