Class: Sarif::EdgeTraversal
- Inherits:
-
Object
- Object
- Sarif::EdgeTraversal
- Defined in:
- lib/sarif/edge_traversal.rb
Overview
Represents the traversal of a single edge during a graph traversal.
Instance Attribute Summary collapse
-
#edge_id ⇒ Object
Returns the value of attribute edge_id.
-
#final_state ⇒ Object
Returns the value of attribute final_state.
-
#message ⇒ Object
Returns the value of attribute message.
-
#properties ⇒ Object
Returns the value of attribute properties.
-
#step_over_edge_count ⇒ Object
Returns the value of attribute step_over_edge_count.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(edge_id:, message: nil, final_state: nil, step_over_edge_count: nil, properties: nil) ⇒ EdgeTraversal
constructor
A new instance of EdgeTraversal.
- #to_h ⇒ Object
- #to_json(pretty: false) ⇒ Object
Constructor Details
#initialize(edge_id:, message: nil, final_state: nil, step_over_edge_count: nil, properties: nil) ⇒ EdgeTraversal
Returns a new instance of EdgeTraversal.
8 9 10 11 12 13 14 |
# File 'lib/sarif/edge_traversal.rb', line 8 def initialize(edge_id:, message: nil, final_state: nil, step_over_edge_count: nil, properties: nil) @edge_id = edge_id @message = @final_state = final_state @step_over_edge_count = step_over_edge_count @properties = properties end |
Instance Attribute Details
#edge_id ⇒ Object
Returns the value of attribute edge_id.
6 7 8 |
# File 'lib/sarif/edge_traversal.rb', line 6 def edge_id @edge_id end |
#final_state ⇒ Object
Returns the value of attribute final_state.
6 7 8 |
# File 'lib/sarif/edge_traversal.rb', line 6 def final_state @final_state end |
#message ⇒ Object
Returns the value of attribute message.
6 7 8 |
# File 'lib/sarif/edge_traversal.rb', line 6 def @message end |
#properties ⇒ Object
Returns the value of attribute properties.
6 7 8 |
# File 'lib/sarif/edge_traversal.rb', line 6 def properties @properties end |
#step_over_edge_count ⇒ Object
Returns the value of attribute step_over_edge_count.
6 7 8 |
# File 'lib/sarif/edge_traversal.rb', line 6 def step_over_edge_count @step_over_edge_count end |
Class Method Details
.from_hash(h) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/sarif/edge_traversal.rb', line 30 def self.from_hash(h) return nil if h.nil? new( edge_id: h["edgeId"], message: Message.from_hash(h["message"]), final_state: h["finalState"], step_over_edge_count: h["stepOverEdgeCount"], properties: h["properties"] ) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
41 42 43 44 |
# File 'lib/sarif/edge_traversal.rb', line 41 def ==(other) return false unless other.is_a?(EdgeTraversal) @edge_id == other.edge_id && @message == other. && @final_state == other.final_state && @step_over_edge_count == other.step_over_edge_count && @properties == other.properties end |
#hash ⇒ Object
48 49 50 |
# File 'lib/sarif/edge_traversal.rb', line 48 def hash [@edge_id, @message, @final_state, @step_over_edge_count, @properties].hash end |
#to_h ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/sarif/edge_traversal.rb', line 16 def to_h h = {} h["edgeId"] = @edge_id h["message"] = @message&.to_h unless @message.nil? h["finalState"] = @final_state unless @final_state.nil? h["stepOverEdgeCount"] = @step_over_edge_count unless @step_over_edge_count.nil? h["properties"] = @properties unless @properties.nil? h end |
#to_json(pretty: false) ⇒ Object
26 27 28 |
# File 'lib/sarif/edge_traversal.rb', line 26 def to_json(pretty: false) pretty ? JSON.pretty_generate(to_h) : JSON.generate(to_h) end |