module Rumanu
Constants
- CONSONANTS
- VERSION
- VOWELS
Pythagoras alphabet
Public Instance Methods
digit_sum(n)
click to toggle source
# File lib/rumanu/helpers.rb, line 5 def digit_sum(n) return 0 if n.zero? 1 + (n - 1) % 9 end
reduce_list(lst, alphabet)
click to toggle source
# File lib/rumanu/helpers.rb, line 11 def reduce_list(lst, alphabet) digit_sum(lst.map { |value| alphabet[value] }.compact.sum) end
valid_date?(str)
click to toggle source
# File lib/rumanu/helpers.rb, line 15 def valid_date?(str) valid_formats = [/\d{2}\.\d{2}\.\d{4}/, %r{\d{2}/\d{2}/\d{4}}, /\d{2}-\d{2}-\d{4}/, /\d{4}-\d{2}-\d{2}/] check_format = valid_formats.map { |f| f.match?(str) && 1 || 0 }.reduce(0, :+) raise ArgumentError, 'Incorrect date format' if check_format.zero? end
valid_hash?(h)
click to toggle source
# File lib/rumanu/helpers.rb, line 21 def valid_hash?(h) raise ArgumentError, 'Object must me a Hash' unless h.is_a? Hash raise ArgumentError, 'Hash can not be empty' unless h.empty? true end