Class: Sarif::EdgeTraversal

Inherits:
Object
  • Object
show all
Defined in:
lib/sarif/edge_traversal.rb

Overview

Represents the traversal of a single edge during a graph traversal.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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 = message
  @final_state = final_state
  @step_over_edge_count = step_over_edge_count
  @properties = properties
end

Instance Attribute Details

#edge_idObject

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_stateObject

Returns the value of attribute final_state.



6
7
8
# File 'lib/sarif/edge_traversal.rb', line 6

def final_state
  @final_state
end

#messageObject

Returns the value of attribute message.



6
7
8
# File 'lib/sarif/edge_traversal.rb', line 6

def message
  @message
end

#propertiesObject

Returns the value of attribute properties.



6
7
8
# File 'lib/sarif/edge_traversal.rb', line 6

def properties
  @properties
end

#step_over_edge_countObject

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.message && @final_state == other.final_state && @step_over_edge_count == other.step_over_edge_count && @properties == other.properties
end

#hashObject



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_hObject



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