Sha256: e683b56ba492c1fc0f53f21587f354441131acdd161671db94f049a48fa589ad
Contents?: true
Size: 937 Bytes
Versions: 3
Compression:
Stored size: 937 Bytes
Contents
module CodiceFiscale module Helpers def intersection string_a, string_or_array_b letters_a = string_a.split '' letters_b = string_or_array_b.respond_to?(:split) ? string_or_array_b.split('') : string_or_array_b selected_letters = letters_a.select { |letter| letters_b.include? letter } selected_letters.join '' end def consonants string intersection string, Alphabet.consonants end def first_three_consonants string intersection(string, Alphabet.consonants)[0..2] end def first_three_vowels string intersection(string, Alphabet.vowels)[0..2] end def truncate_and_right_pad_with_three_x string string[0..2].ljust 3, 'X' end def first_three_consonants_than_vowels string string.upcase! code = first_three_consonants string code << first_three_vowels(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-0.0.8 | lib/codice_fiscale/helpers.rb |
codice-fiscale-0.0.7 | lib/codice_fiscale/helpers.rb |
codice-fiscale-0.0.6 | lib/codice_fiscale/helpers.rb |