Class: Sarif::TranslationMetadata
- Inherits:
-
Object
- Object
- Sarif::TranslationMetadata
- Defined in:
- lib/sarif/translation_metadata.rb
Overview
Provides additional metadata related to translation.
Instance Attribute Summary collapse
-
#download_uri ⇒ Object
Returns the value of attribute download_uri.
-
#full_description ⇒ Object
Returns the value of attribute full_description.
-
#full_name ⇒ Object
Returns the value of attribute full_name.
-
#information_uri ⇒ Object
Returns the value of attribute information_uri.
-
#name ⇒ Object
Returns the value of attribute name.
-
#properties ⇒ Object
Returns the value of attribute properties.
-
#short_description ⇒ Object
Returns the value of attribute short_description.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(name:, full_name: nil, short_description: nil, full_description: nil, download_uri: nil, information_uri: nil, properties: nil) ⇒ TranslationMetadata
constructor
A new instance of TranslationMetadata.
- #to_h ⇒ Object
- #to_json(pretty: false) ⇒ Object
Constructor Details
#initialize(name:, full_name: nil, short_description: nil, full_description: nil, download_uri: nil, information_uri: nil, properties: nil) ⇒ TranslationMetadata
Returns a new instance of TranslationMetadata.
8 9 10 11 12 13 14 15 16 |
# File 'lib/sarif/translation_metadata.rb', line 8 def initialize(name:, full_name: nil, short_description: nil, full_description: nil, download_uri: nil, information_uri: nil, properties: nil) @name = name @full_name = full_name @short_description = short_description @full_description = full_description @download_uri = download_uri @information_uri = information_uri @properties = properties end |
Instance Attribute Details
#download_uri ⇒ Object
Returns the value of attribute download_uri.
6 7 8 |
# File 'lib/sarif/translation_metadata.rb', line 6 def download_uri @download_uri end |
#full_description ⇒ Object
Returns the value of attribute full_description.
6 7 8 |
# File 'lib/sarif/translation_metadata.rb', line 6 def full_description @full_description end |
#full_name ⇒ Object
Returns the value of attribute full_name.
6 7 8 |
# File 'lib/sarif/translation_metadata.rb', line 6 def full_name @full_name end |
#information_uri ⇒ Object
Returns the value of attribute information_uri.
6 7 8 |
# File 'lib/sarif/translation_metadata.rb', line 6 def information_uri @information_uri end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/sarif/translation_metadata.rb', line 6 def name @name end |
#properties ⇒ Object
Returns the value of attribute properties.
6 7 8 |
# File 'lib/sarif/translation_metadata.rb', line 6 def properties @properties end |
#short_description ⇒ Object
Returns the value of attribute short_description.
6 7 8 |
# File 'lib/sarif/translation_metadata.rb', line 6 def short_description @short_description end |
Class Method Details
.from_hash(h) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/sarif/translation_metadata.rb', line 34 def self.from_hash(h) return nil if h.nil? new( name: h["name"], full_name: h["fullName"], short_description: MultiformatMessageString.from_hash(h["shortDescription"]), full_description: MultiformatMessageString.from_hash(h["fullDescription"]), download_uri: h["downloadUri"], information_uri: h["informationUri"], properties: h["properties"] ) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
47 48 49 50 |
# File 'lib/sarif/translation_metadata.rb', line 47 def ==(other) return false unless other.is_a?(TranslationMetadata) @name == other.name && @full_name == other.full_name && @short_description == other.short_description && @full_description == other.full_description && @download_uri == other.download_uri && @information_uri == other.information_uri && @properties == other.properties end |
#hash ⇒ Object
54 55 56 |
# File 'lib/sarif/translation_metadata.rb', line 54 def hash [@name, @full_name, @short_description, @full_description, @download_uri, @information_uri, @properties].hash end |
#to_h ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/sarif/translation_metadata.rb', line 18 def to_h h = {} h["name"] = @name h["fullName"] = @full_name unless @full_name.nil? h["shortDescription"] = @short_description&.to_h unless @short_description.nil? h["fullDescription"] = @full_description&.to_h unless @full_description.nil? h["downloadUri"] = @download_uri unless @download_uri.nil? h["informationUri"] = @information_uri unless @information_uri.nil? h["properties"] = @properties unless @properties.nil? h end |
#to_json(pretty: false) ⇒ Object
30 31 32 |
# File 'lib/sarif/translation_metadata.rb', line 30 def to_json(pretty: false) pretty ? JSON.pretty_generate(to_h) : JSON.generate(to_h) end |