Class: Sarif::MultiformatMessageString
- Inherits:
-
Object
- Object
- Sarif::MultiformatMessageString
- Defined in:
- lib/sarif/multiformat_message_string.rb
Overview
A message string or message format string rendered in multiple formats.
Instance Attribute Summary collapse
-
#markdown ⇒ Object
Returns the value of attribute markdown.
-
#properties ⇒ Object
Returns the value of attribute properties.
-
#text ⇒ Object
Returns the value of attribute text.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(text:, markdown: nil, properties: nil) ⇒ MultiformatMessageString
constructor
A new instance of MultiformatMessageString.
- #to_h ⇒ Object
- #to_json(pretty: false) ⇒ Object
Constructor Details
#initialize(text:, markdown: nil, properties: nil) ⇒ MultiformatMessageString
Returns a new instance of MultiformatMessageString.
8 9 10 11 12 |
# File 'lib/sarif/multiformat_message_string.rb', line 8 def initialize(text:, markdown: nil, properties: nil) @text = text @markdown = markdown @properties = properties end |
Instance Attribute Details
#markdown ⇒ Object
Returns the value of attribute markdown.
6 7 8 |
# File 'lib/sarif/multiformat_message_string.rb', line 6 def markdown @markdown end |
#properties ⇒ Object
Returns the value of attribute properties.
6 7 8 |
# File 'lib/sarif/multiformat_message_string.rb', line 6 def properties @properties end |
#text ⇒ Object
Returns the value of attribute text.
6 7 8 |
# File 'lib/sarif/multiformat_message_string.rb', line 6 def text @text end |
Class Method Details
.from_hash(h) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/sarif/multiformat_message_string.rb', line 26 def self.from_hash(h) return nil if h.nil? new( text: h["text"], markdown: h["markdown"], properties: h["properties"] ) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
35 36 37 38 |
# File 'lib/sarif/multiformat_message_string.rb', line 35 def ==(other) return false unless other.is_a?(MultiformatMessageString) @text == other.text && @markdown == other.markdown && @properties == other.properties end |
#hash ⇒ Object
42 43 44 |
# File 'lib/sarif/multiformat_message_string.rb', line 42 def hash [@text, @markdown, @properties].hash end |
#to_h ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/sarif/multiformat_message_string.rb', line 14 def to_h h = {} h["text"] = @text h["markdown"] = @markdown unless @markdown.nil? h["properties"] = @properties unless @properties.nil? h end |
#to_json(pretty: false) ⇒ Object
22 23 24 |
# File 'lib/sarif/multiformat_message_string.rb', line 22 def to_json(pretty: false) pretty ? JSON.pretty_generate(to_h) : JSON.generate(to_h) end |