Sha256: 2bd46eb56cbc81e1fc15f119c0ef84392e70670163075beeaf60e1216255cb0b

Contents?: true

Size: 600 Bytes

Versions: 4

Compression:

Stored size: 600 Bytes

Contents

module LensProtocol
  module OMA
    class Formatter
      # Generates the OMA string from a Message
      def format message, line_separator: "\r\n", start_of_message: '', end_of_message: '', **opts
        [
          start_of_message,
          format_lines(message, **opts).join(line_separator),
          line_separator,
          end_of_message
        ].join
      end

      def format_lines message, types: {}
        types = TYPES.merge(types)
        message.records.values.flat_map do |record|
          types[record.label].format(record, message)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lens_protocol-0.1.3 lib/lens_protocol/oma/formatter.rb
lens_protocol-0.1.2 lib/lens_protocol/oma/formatter.rb
lens_protocol-0.1.1 lib/lens_protocol/oma/formatter.rb
lens_protocol-0.1.0 lib/lens_protocol/oma/formatter.rb