Sha256: e06a63c5b119faee7d31211e0a7068378da1e52ab8eadd564fc7926ea4e916bd

Contents?: true

Size: 506 Bytes

Versions: 4

Compression:

Stored size: 506 Bytes

Contents

# frozen_string_literal: true

module FidoMetadata
  module Coercer
    class MagicNumber
      def initialize(mapping, array: false)
        @mapping = mapping
        @array = array
      end

      def coerce(values)
        if @array
          return values unless values.all? { |value| value.is_a?(Integer) }

          values.map { |value| @mapping[value] }.compact
        else
          return values unless values.is_a?(Integer)

          @mapping[values]
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fido_metadata-0.4.0 lib/fido_metadata/coercer/magic_number.rb
fido_metadata-0.3.0 lib/fido_metadata/coercer/magic_number.rb
fido_metadata-0.2.0 lib/fido_metadata/coercer/magic_number.rb
fido_metadata-0.1.0 lib/fido_metadata/coercer/magic_number.rb