Class: Sarif::CodeFlow
- Inherits:
-
Object
- Object
- Sarif::CodeFlow
- Defined in:
- lib/sarif/code_flow.rb
Overview
A set of threadFlows which together describe a pattern of code execution relevant to detecting a result.
Instance Attribute Summary collapse
-
#message ⇒ Object
Returns the value of attribute message.
-
#properties ⇒ Object
Returns the value of attribute properties.
-
#thread_flows ⇒ Object
Returns the value of attribute thread_flows.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(message: nil, thread_flows:, properties: nil) ⇒ CodeFlow
constructor
A new instance of CodeFlow.
- #to_h ⇒ Object
- #to_json(pretty: false) ⇒ Object
Constructor Details
#initialize(message: nil, thread_flows:, properties: nil) ⇒ CodeFlow
Returns a new instance of CodeFlow.
8 9 10 11 12 |
# File 'lib/sarif/code_flow.rb', line 8 def initialize(message: nil, thread_flows:, properties: nil) @message = @thread_flows = thread_flows @properties = properties end |
Instance Attribute Details
#message ⇒ Object
Returns the value of attribute message.
6 7 8 |
# File 'lib/sarif/code_flow.rb', line 6 def @message end |
#properties ⇒ Object
Returns the value of attribute properties.
6 7 8 |
# File 'lib/sarif/code_flow.rb', line 6 def properties @properties end |
#thread_flows ⇒ Object
Returns the value of attribute thread_flows.
6 7 8 |
# File 'lib/sarif/code_flow.rb', line 6 def thread_flows @thread_flows end |
Class Method Details
.from_hash(h) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/sarif/code_flow.rb', line 26 def self.from_hash(h) return nil if h.nil? new( message: Message.from_hash(h["message"]), thread_flows: h["threadFlows"]&.map { |v| ThreadFlow.from_hash(v) }, properties: h["properties"] ) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
35 36 37 38 |
# File 'lib/sarif/code_flow.rb', line 35 def ==(other) return false unless other.is_a?(CodeFlow) @message == other. && @thread_flows == other.thread_flows && @properties == other.properties end |
#hash ⇒ Object
42 43 44 |
# File 'lib/sarif/code_flow.rb', line 42 def hash [@message, @thread_flows, @properties].hash end |
#to_h ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/sarif/code_flow.rb', line 14 def to_h h = {} h["message"] = @message&.to_h unless @message.nil? h["threadFlows"] = @thread_flows&.map(&:to_h) h["properties"] = @properties unless @properties.nil? h end |
#to_json(pretty: false) ⇒ Object
22 23 24 |
# File 'lib/sarif/code_flow.rb', line 22 def to_json(pretty: false) pretty ? JSON.pretty_generate(to_h) : JSON.generate(to_h) end |