Class: Sarif::Address
- Inherits:
-
Object
- Object
- Sarif::Address
- Defined in:
- lib/sarif/address.rb
Overview
A physical or virtual address, or a range of addresses, in an ‘addressable region’ (memory or a binary file).
Instance Attribute Summary collapse
-
#absolute_address ⇒ Object
Returns the value of attribute absolute_address.
-
#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.
-
#length ⇒ Object
Returns the value of attribute length.
-
#name ⇒ Object
Returns the value of attribute name.
-
#offset_from_parent ⇒ Object
Returns the value of attribute offset_from_parent.
-
#parent_index ⇒ Object
Returns the value of attribute parent_index.
-
#properties ⇒ Object
Returns the value of attribute properties.
-
#relative_address ⇒ Object
Returns the value of attribute relative_address.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(absolute_address: -1,, relative_address: nil, length: nil, kind: nil, name: nil, fully_qualified_name: nil, offset_from_parent: nil, index: -1,, parent_index: -1,, properties: nil) ⇒ Address
constructor
A new instance of Address.
- #to_h ⇒ Object
- #to_json(pretty: false) ⇒ Object
Constructor Details
#initialize(absolute_address: -1,, relative_address: nil, length: nil, kind: nil, name: nil, fully_qualified_name: nil, offset_from_parent: nil, index: -1,, parent_index: -1,, properties: nil) ⇒ Address
Returns a new instance of Address.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/sarif/address.rb', line 8 def initialize(absolute_address: -1, relative_address: nil, length: nil, kind: nil, name: nil, fully_qualified_name: nil, offset_from_parent: nil, index: -1, parent_index: -1, properties: nil) @absolute_address = absolute_address @relative_address = relative_address @length = length @kind = kind @name = name @fully_qualified_name = fully_qualified_name @offset_from_parent = offset_from_parent @index = index @parent_index = parent_index @properties = properties end |
Instance Attribute Details
#absolute_address ⇒ Object
Returns the value of attribute absolute_address.
6 7 8 |
# File 'lib/sarif/address.rb', line 6 def absolute_address @absolute_address end |
#fully_qualified_name ⇒ Object
Returns the value of attribute fully_qualified_name.
6 7 8 |
# File 'lib/sarif/address.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/address.rb', line 6 def index @index end |
#kind ⇒ Object
Returns the value of attribute kind.
6 7 8 |
# File 'lib/sarif/address.rb', line 6 def kind @kind end |
#length ⇒ Object
Returns the value of attribute length.
6 7 8 |
# File 'lib/sarif/address.rb', line 6 def length @length end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/sarif/address.rb', line 6 def name @name end |
#offset_from_parent ⇒ Object
Returns the value of attribute offset_from_parent.
6 7 8 |
# File 'lib/sarif/address.rb', line 6 def offset_from_parent @offset_from_parent end |
#parent_index ⇒ Object
Returns the value of attribute parent_index.
6 7 8 |
# File 'lib/sarif/address.rb', line 6 def parent_index @parent_index end |
#properties ⇒ Object
Returns the value of attribute properties.
6 7 8 |
# File 'lib/sarif/address.rb', line 6 def properties @properties end |
#relative_address ⇒ Object
Returns the value of attribute relative_address.
6 7 8 |
# File 'lib/sarif/address.rb', line 6 def relative_address @relative_address end |
Class Method Details
.from_hash(h) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/sarif/address.rb', line 40 def self.from_hash(h) return nil if h.nil? new( absolute_address: h["absoluteAddress"] || -1, relative_address: h["relativeAddress"], length: h["length"], kind: h["kind"], name: h["name"], fully_qualified_name: h["fullyQualifiedName"], offset_from_parent: h["offsetFromParent"], index: h["index"] || -1, parent_index: h["parentIndex"] || -1, properties: h["properties"] ) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
56 57 58 59 |
# File 'lib/sarif/address.rb', line 56 def ==(other) return false unless other.is_a?(Address) @absolute_address == other.absolute_address && @relative_address == other.relative_address && @length == other.length && @kind == other.kind && @name == other.name && @fully_qualified_name == other.fully_qualified_name && @offset_from_parent == other.offset_from_parent && @index == other.index && @parent_index == other.parent_index && @properties == other.properties end |
#hash ⇒ Object
63 64 65 |
# File 'lib/sarif/address.rb', line 63 def hash [@absolute_address, @relative_address, @length, @kind, @name, @fully_qualified_name, @offset_from_parent, @index, @parent_index, @properties].hash end |
#to_h ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/sarif/address.rb', line 21 def to_h h = {} h["absoluteAddress"] = @absolute_address if @absolute_address && @absolute_address != -1 h["relativeAddress"] = @relative_address unless @relative_address.nil? h["length"] = @length unless @length.nil? h["kind"] = @kind unless @kind.nil? h["name"] = @name unless @name.nil? h["fullyQualifiedName"] = @fully_qualified_name unless @fully_qualified_name.nil? h["offsetFromParent"] = @offset_from_parent unless @offset_from_parent.nil? h["index"] = @index if @index && @index != -1 h["parentIndex"] = @parent_index if @parent_index && @parent_index != -1 h["properties"] = @properties unless @properties.nil? h end |
#to_json(pretty: false) ⇒ Object
36 37 38 |
# File 'lib/sarif/address.rb', line 36 def to_json(pretty: false) pretty ? JSON.pretty_generate(to_h) : JSON.generate(to_h) end |