Sha256: bf6931828163f4b3dc974522fff8083c320ab66d72f8801788f35e7d25e17e66
Contents?: true
Size: 832 Bytes
Versions: 3
Compression:
Stored size: 832 Bytes
Contents
module CodiceFiscale module Helpers def multiset_intersection array_a, array_b array_a.select { |letter| array_b.include? letter } end def consonants string multiset_intersection(string.chars, Alphabet.consonants).join end def first_three_consonants string multiset_intersection(string.chars, Alphabet.consonants)[0..2].join end def first_three_vowels string multiset_intersection(string.chars, Alphabet.vowels)[0..2].join end def truncate_and_right_pad_with_three_x string string[0..2].ljust 3, 'X' end def first_three_consonants_than_vowels string upcase_string = string.upcase code = first_three_consonants upcase_string code << first_three_vowels(upcase_string) truncate_and_right_pad_with_three_x code end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
codice-fiscale-1.0.1 | lib/codice_fiscale/helpers.rb |
codice-fiscale-1.0.0 | lib/codice_fiscale/helpers.rb |
codice-fiscale-0.0.9 | lib/codice_fiscale/helpers.rb |