Class: Sarif::LocationRelationship
- Inherits:
-
Object
- Object
- Sarif::LocationRelationship
- Defined in:
- lib/sarif/location_relationship.rb
Overview
Information about the relation of one location to another.
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#kinds ⇒ Object
Returns the value of attribute kinds.
-
#properties ⇒ Object
Returns the value of attribute properties.
-
#target ⇒ Object
Returns the value of attribute target.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(target:, kinds: ["relevant"], description: nil, properties: nil) ⇒ LocationRelationship
constructor
A new instance of LocationRelationship.
- #to_h ⇒ Object
- #to_json(pretty: false) ⇒ Object
Constructor Details
#initialize(target:, kinds: ["relevant"], description: nil, properties: nil) ⇒ LocationRelationship
Returns a new instance of LocationRelationship.
8 9 10 11 12 13 |
# File 'lib/sarif/location_relationship.rb', line 8 def initialize(target:, kinds: ["relevant"], description: nil, properties: nil) @target = target @kinds = kinds @description = description @properties = properties end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
6 7 8 |
# File 'lib/sarif/location_relationship.rb', line 6 def description @description end |
#kinds ⇒ Object
Returns the value of attribute kinds.
6 7 8 |
# File 'lib/sarif/location_relationship.rb', line 6 def kinds @kinds end |
#properties ⇒ Object
Returns the value of attribute properties.
6 7 8 |
# File 'lib/sarif/location_relationship.rb', line 6 def properties @properties end |
#target ⇒ Object
Returns the value of attribute target.
6 7 8 |
# File 'lib/sarif/location_relationship.rb', line 6 def target @target end |
Class Method Details
.from_hash(h) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/sarif/location_relationship.rb', line 28 def self.from_hash(h) return nil if h.nil? new( target: h["target"], kinds: h.key?("kinds") ? h["kinds"] : ["relevant"], description: Message.from_hash(h["description"]), properties: h["properties"] ) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
38 39 40 41 |
# File 'lib/sarif/location_relationship.rb', line 38 def ==(other) return false unless other.is_a?(LocationRelationship) @target == other.target && @kinds == other.kinds && @description == other.description && @properties == other.properties end |
#hash ⇒ Object
45 46 47 |
# File 'lib/sarif/location_relationship.rb', line 45 def hash [@target, @kinds, @description, @properties].hash end |
#to_h ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/sarif/location_relationship.rb', line 15 def to_h h = {} h["target"] = @target h["kinds"] = @kinds if @kinds&.any? h["description"] = @description&.to_h unless @description.nil? h["properties"] = @properties unless @properties.nil? h end |
#to_json(pretty: false) ⇒ Object
24 25 26 |
# File 'lib/sarif/location_relationship.rb', line 24 def to_json(pretty: false) pretty ? JSON.pretty_generate(to_h) : JSON.generate(to_h) end |