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