Class: RFC5424::StructuredData

Inherits:
Object
  • Object
show all
Defined in:
lib/rfc5424/formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_elementsObject (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_idObject (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_sObject



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