Sha256: 9fe23fc704571d243e840ef619c6d21032fa9f65913f2880904894186c8dd009

Contents?: true

Size: 548 Bytes

Versions: 4

Compression:

Stored size: 548 Bytes

Contents

require 'digest'

module Ecoportal
  module API
    module Common
      module Content
        module StringDigest
          MAX_HASH_LABEL = 64

          # Calculates the Hash of the field based on label
          def hash_label(str)
            return false unless str
            label = str.downcase.gsub(/[^A-Za-z]+/,"-").slice(0, MAX_HASH_LABEL)
            return false unless label.length >= 3
            return "z" +  Digest::MD5.hexdigest(label).slice(0, 8);
          end

        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ecoportal-api-oozes-0.5.8 lib/ecoportal/api/common/content/string_digest.rb
ecoportal-api-oozes-0.5.7 lib/ecoportal/api/common/content/string_digest.rb
ecoportal-api-oozes-0.5.6 lib/ecoportal/api/common/content/string_digest.rb
ecoportal-api-oozes-0.5.5 lib/ecoportal/api/common/content/string_digest.rb