Sha256: 028d42d953a52d71f6dfb7c63011822aefc9052d396644de213d36ad27b7f537

Contents?: true

Size: 668 Bytes

Versions: 2

Compression:

Stored size: 668 Bytes

Contents

module LensProtocol
  module OMA
    module Types
      class Chiral < Type
        def parse line, next_lines
          values = make_chiral parse_values line.data
          [values, next_lines]
        end

        def wrap value, _message_hash, _label
          make_chiral Array(value)
        end

        def format label, values
          data = values.select(&:present?).empty? ? '' : format_values(values)
          build_line label, data
        end

        private

        def make_chiral values
          if values.size <= 1
            [values[0], values[0]]
          else
            values[0..1]
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lens_protocol-0.2.1 lib/lens_protocol/oma/types/chiral.rb
lens_protocol-0.2.0 lib/lens_protocol/oma/types/chiral.rb