Class: Sarif::ThreadFlow
- Inherits:
-
Object
- Object
- Sarif::ThreadFlow
- Defined in:
- lib/sarif/thread_flow.rb
Overview
Describes a sequence of code locations that specify a path through a single thread of execution such as an operating system or fiber.
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#immutable_state ⇒ Object
Returns the value of attribute immutable_state.
-
#initial_state ⇒ Object
Returns the value of attribute initial_state.
-
#locations ⇒ Object
Returns the value of attribute locations.
-
#message ⇒ Object
Returns the value of attribute message.
-
#properties ⇒ Object
Returns the value of attribute properties.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(id: nil, message: nil, initial_state: nil, immutable_state: nil, locations:, properties: nil) ⇒ ThreadFlow
constructor
A new instance of ThreadFlow.
- #to_h ⇒ Object
- #to_json(pretty: false) ⇒ Object
Constructor Details
#initialize(id: nil, message: nil, initial_state: nil, immutable_state: nil, locations:, properties: nil) ⇒ ThreadFlow
Returns a new instance of ThreadFlow.
8 9 10 11 12 13 14 15 |
# File 'lib/sarif/thread_flow.rb', line 8 def initialize(id: nil, message: nil, initial_state: nil, immutable_state: nil, locations:, properties: nil) @id = id @message = @initial_state = initial_state @immutable_state = immutable_state @locations = locations @properties = properties end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/sarif/thread_flow.rb', line 6 def id @id end |
#immutable_state ⇒ Object
Returns the value of attribute immutable_state.
6 7 8 |
# File 'lib/sarif/thread_flow.rb', line 6 def immutable_state @immutable_state end |
#initial_state ⇒ Object
Returns the value of attribute initial_state.
6 7 8 |
# File 'lib/sarif/thread_flow.rb', line 6 def initial_state @initial_state end |
#locations ⇒ Object
Returns the value of attribute locations.
6 7 8 |
# File 'lib/sarif/thread_flow.rb', line 6 def locations @locations end |
#message ⇒ Object
Returns the value of attribute message.
6 7 8 |
# File 'lib/sarif/thread_flow.rb', line 6 def @message end |
#properties ⇒ Object
Returns the value of attribute properties.
6 7 8 |
# File 'lib/sarif/thread_flow.rb', line 6 def properties @properties end |
Class Method Details
.from_hash(h) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/sarif/thread_flow.rb', line 32 def self.from_hash(h) return nil if h.nil? new( id: h["id"], message: Message.from_hash(h["message"]), initial_state: h["initialState"], immutable_state: h["immutableState"], locations: h["locations"]&.map { |v| ThreadFlowLocation.from_hash(v) }, properties: h["properties"] ) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
44 45 46 47 |
# File 'lib/sarif/thread_flow.rb', line 44 def ==(other) return false unless other.is_a?(ThreadFlow) @id == other.id && @message == other. && @initial_state == other.initial_state && @immutable_state == other.immutable_state && @locations == other.locations && @properties == other.properties end |
#hash ⇒ Object
51 52 53 |
# File 'lib/sarif/thread_flow.rb', line 51 def hash [@id, @message, @initial_state, @immutable_state, @locations, @properties].hash end |
#to_h ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/sarif/thread_flow.rb', line 17 def to_h h = {} h["id"] = @id unless @id.nil? h["message"] = @message&.to_h unless @message.nil? h["initialState"] = @initial_state unless @initial_state.nil? h["immutableState"] = @immutable_state unless @immutable_state.nil? h["locations"] = @locations&.map(&:to_h) h["properties"] = @properties unless @properties.nil? h end |
#to_json(pretty: false) ⇒ Object
28 29 30 |
# File 'lib/sarif/thread_flow.rb', line 28 def to_json(pretty: false) pretty ? JSON.pretty_generate(to_h) : JSON.generate(to_h) end |