Class: RFC5424::StructuredData
- Inherits:
-
Object
- Object
- RFC5424::StructuredData
- Defined in:
- lib/rfc5424/formatter.rb
Instance Attribute Summary collapse
-
#sd_elements ⇒ Object
readonly
Returns the value of attribute sd_elements.
-
#sd_id ⇒ Object
readonly
Returns the value of attribute sd_id.
Instance Method Summary collapse
-
#initialize(sd_id:, sd_elements: {}) ⇒ StructuredData
constructor
A new instance of StructuredData.
- #to_s ⇒ Object
Constructor Details
#initialize(sd_id:, sd_elements: {}) ⇒ StructuredData
Returns a new instance of StructuredData.
33 34 35 36 |
# File 'lib/rfc5424/formatter.rb', line 33 def initialize(sd_id:, sd_elements: {}) @sd_id = sd_id @sd_elements = sd_elements end |
Instance Attribute Details
#sd_elements ⇒ Object (readonly)
Returns the value of attribute sd_elements.
31 32 33 |
# File 'lib/rfc5424/formatter.rb', line 31 def sd_elements @sd_elements end |
#sd_id ⇒ Object (readonly)
Returns the value of attribute sd_id.
31 32 33 |
# File 'lib/rfc5424/formatter.rb', line 31 def sd_id @sd_id end |
Instance Method Details
#to_s ⇒ Object
38 39 40 41 42 43 |
# File 'lib/rfc5424/formatter.rb', line 38 def to_s el = @sd_elements.inject("") do |elements, tuple| elements + %{ #{tuple.first}="#{tuple.last}"} end %{[#{sd_id}#{el}]} end |