Class: Sarif::LogicalLocation

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

Overview

A logical location of a construct that produced a result.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_nameObject

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_nameObject

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

#indexObject

Returns the value of attribute index.



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

def index
  @index
end

#kindObject

Returns the value of attribute kind.



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

def kind
  @kind
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#parent_indexObject

Returns the value of attribute parent_index.



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

def parent_index
  @parent_index
end

#propertiesObject

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

#hashObject



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_hObject



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