module Ecoportal::API::Common::Content::StringDigest
Constants
- MAX_HASH_LABEL
Public Instance Methods
hash_label(str)
click to toggle source
Calculates the Hash of the field based on label
# File lib/ecoportal/api/common/content/string_digest.rb, line 18 def hash_label(str) return nil unless lbl = indexable_label(str) "z" + Digest::MD5.hexdigest(lbl).slice(0, 8); end
indexable_label(str)
click to toggle source
# File lib/ecoportal/api/common/content/string_digest.rb, line 10 def indexable_label(str) return nil unless str lbl = str.downcase.gsub(/[^A-Za-z]+/,"-").slice(0, MAX_HASH_LABEL) return nil unless lbl.length >= 3 lbl end