Module: Rumanu
- Included in:
- Numerology
- Defined in:
- lib/rumanu/helpers.rb,
lib/rumanu/meaning.rb,
lib/rumanu/version.rb,
lib/rumanu/alphabets.rb,
lib/rumanu/numerology.rb
Defined Under Namespace
Modules: Meaning
Classes: Numerology
Constant Summary
collapse
- VERSION =
"0.11.1"
- PY_VOWELS =
{ 'a' => 1, 'á' => 1, 'e' => 5, 'é' => 5, 'i' => 9,
'í' => 9, 'o' => 6, 'ó' => 6, 'u' => 3, 'ú' => 3, 'ü' => 3 }
- PY_CONSONANTS =
{ 'b' => 2, 'c' => 3, 'd' => 4, 'f' => 6, 'g' => 7,
'h' => 8, 'j' => 1, 'k' => 2, 'l' => 3, 'm' => 4, 'n' => 5,
'p' => 7, 'q' => 8, 'r' => 9, 's' => 1, 't' => 2, 'v' => 4,
'w' => 5, 'x' => 6, 'y' => 7, 'z' => 8 }
Instance Method Summary
collapse
Instance Method Details
#digit_sum(n) ⇒ Object
4
5
6
7
8
|
# File 'lib/rumanu/helpers.rb', line 4
def digit_sum(n)
cum = n.digits.sum
cum = digit_sum(cum) unless cum.to_s.length == 1
return cum
end
|
#reduce_list(l, alphabet) ⇒ Object
10
11
12
13
14
15
16
17
18
|
# File 'lib/rumanu/helpers.rb', line 10
def reduce_list(l,alphabet)
init = 0
l.each do |c|
alphabet.each do |k,v|
init += v if c == k
end
end
digit_sum(init)
end
|
#valid_date?(str) ⇒ Boolean
20
21
22
23
24
|
# File 'lib/rumanu/helpers.rb', line 20
def valid_date?(str)
valid_formats = [/\d{2}\.\d{2}\.\d{4}/, /\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.new("Incorrect date format") if check_format.zero?
end
|
#valid_hash?(h) ⇒ Boolean
26
27
28
29
30
|
# File 'lib/rumanu/helpers.rb', line 26
def valid_hash?(h)
raise ArgumentError.new("Object must me a Hash") unless h.is_a? Hash
raise ArgumentError.new("Hash can not be empty") unless h.empty? true
end
|