Class: Sarif::LogicalLocation
- Inherits:
-
Object
- Object
- Sarif::LogicalLocation
- Defined in:
- lib/sarif/logical_location.rb
Overview
A logical location of a construct that produced a result.
Instance Attribute Summary collapse
-
#decorated_name ⇒ Object
Returns the value of attribute decorated_name.
-
#fully_qualified_name ⇒ Object
Returns the value of attribute fully_qualified_name.
-
#index ⇒ Object
Returns the value of attribute index.
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent_index ⇒ Object
Returns the value of attribute parent_index.
-
#properties ⇒ Object
Returns the value of attribute properties.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(name: nil, index: -1,, fully_qualified_name: nil, decorated_name: nil, parent_index: -1,, kind: nil, properties: nil) ⇒ LogicalLocation
constructor
A new instance of LogicalLocation.
- #to_h ⇒ Object
- #to_json(pretty: false) ⇒ Object
Constructor Details
#initialize(name: nil, index: -1,, fully_qualified_name: nil, decorated_name: nil, parent_index: -1,, kind: nil, properties: nil) ⇒ LogicalLocation
Returns a new instance of LogicalLocation.
8 9 10 11 12 13 14 15 16 |
# File 'lib/sarif/logical_location.rb', line 8 def initialize(name: nil, index: -1, fully_qualified_name: nil, decorated_name: nil, parent_index: -1, kind: nil, properties: nil) @name = name @index = index @fully_qualified_name = fully_qualified_name @decorated_name = decorated_name @parent_index = parent_index @kind = kind @properties = properties end |
Instance Attribute Details
#decorated_name ⇒ Object
Returns the value of attribute decorated_name.
6 7 8 |
# File 'lib/sarif/logical_location.rb', line 6 def decorated_name @decorated_name end |
#fully_qualified_name ⇒ Object
Returns the value of attribute fully_qualified_name.
6 7 8 |
# File 'lib/sarif/logical_location.rb', line 6 def fully_qualified_name @fully_qualified_name end |
#index ⇒ Object
Returns the value of attribute index.
6 7 8 |
# File 'lib/sarif/logical_location.rb', line 6 def index @index end |
#kind ⇒ Object
Returns the value of attribute kind.
6 7 8 |
# File 'lib/sarif/logical_location.rb', line 6 def kind @kind end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/sarif/logical_location.rb', line 6 def name @name end |
#parent_index ⇒ Object
Returns the value of attribute parent_index.
6 7 8 |
# File 'lib/sarif/logical_location.rb', line 6 def parent_index @parent_index end |
#properties ⇒ Object
Returns the value of attribute properties.
6 7 8 |
# File 'lib/sarif/logical_location.rb', line 6 def properties @properties end |
Class Method Details
.from_hash(h) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/sarif/logical_location.rb', line 34 def self.from_hash(h) return nil if h.nil? new( name: h["name"], index: h["index"] || -1, fully_qualified_name: h["fullyQualifiedName"], decorated_name: h["decoratedName"], parent_index: h["parentIndex"] || -1, kind: h["kind"], properties: h["properties"] ) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
47 48 49 50 |
# File 'lib/sarif/logical_location.rb', line 47 def ==(other) return false unless other.is_a?(LogicalLocation) @name == other.name && @index == other.index && @fully_qualified_name == other.fully_qualified_name && @decorated_name == other.decorated_name && @parent_index == other.parent_index && @kind == other.kind && @properties == other.properties end |
#hash ⇒ Object
54 55 56 |
# File 'lib/sarif/logical_location.rb', line 54 def hash [@name, @index, @fully_qualified_name, @decorated_name, @parent_index, @kind, @properties].hash end |
#to_h ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/sarif/logical_location.rb', line 18 def to_h h = {} h["name"] = @name unless @name.nil? h["index"] = @index if @index && @index != -1 h["fullyQualifiedName"] = @fully_qualified_name unless @fully_qualified_name.nil? h["decoratedName"] = @decorated_name unless @decorated_name.nil? h["parentIndex"] = @parent_index if @parent_index && @parent_index != -1 h["kind"] = @kind unless @kind.nil? h["properties"] = @properties unless @properties.nil? h end |
#to_json(pretty: false) ⇒ Object
30 31 32 |
# File 'lib/sarif/logical_location.rb', line 30 def to_json(pretty: false) pretty ? JSON.pretty_generate(to_h) : JSON.generate(to_h) end |