class Rumanu::Numerology

Attributes

alphabet[R]
consonants[RW]
dob[R]
vowels[RW]

Public Class Methods

new(name = 'Vance Louis Wheeler', dob = '03/08/1944') click to toggle source
# File lib/rumanu/numerology.rb, line 8
def initialize(name = 'Vance Louis Wheeler', dob = '03/08/1944')
  @vowels = VOWELS
  @consonants = CONSONANTS
  @alphabet = @vowels.merge @consonants
  @name = name
  @dob = dob
end

Public Instance Methods

destiny() click to toggle source
# File lib/rumanu/numerology.rb, line 39
def destiny
  r = dob.split(%r{\.|-|/}).inject(0) { |sum, element| sum + element.to_i }
  value = digit_sum(r)
  return value unless value.to_s.length > 1

  digit_sum(value)
end
dob=(dob) click to toggle source
# File lib/rumanu/numerology.rb, line 25
def dob=(dob)
  validate_dob(dob)
  @dob = dob
end
expression() click to toggle source

Sum of all name's characters

# File lib/rumanu/numerology.rb, line 58
def expression
  reduce_list(prep_name, @alphabet)
end
motivation() click to toggle source

Sum of all name's vowels

# File lib/rumanu/numerology.rb, line 48
def motivation
  reduce_list(prep_name, @vowels)
end
name() click to toggle source
# File lib/rumanu/numerology.rb, line 21
def name
  @name.split.map(&:capitalize).join(' ').dup
end
name=(name) click to toggle source
# File lib/rumanu/numerology.rb, line 16
def name=(name)
  validate_name(name)
  @name = name
end
personality() click to toggle source

Sum of all name's consonants

# File lib/rumanu/numerology.rb, line 53
def personality
  reduce_list(prep_name, @consonants)
end

Private Instance Methods

prep_name() click to toggle source

Private methods

# File lib/rumanu/numerology.rb, line 64
def prep_name
  @name.downcase.split('').delete_if { |i| i == ' ' }
end
validate_alphabet(arg) click to toggle source
# File lib/rumanu/numerology.rb, line 76
def validate_alphabet(arg)
  valid_hash?(arg)
  valid_alphabet = arg.map { |k, v| k.is_a?(String) && v.is_a?(Integer) && 1 || 0 }.reduce(0, :+)
  raise ArgumentError, 'Invalid Alphabet' unless valid_alphabet > 0
end
validate_dob(arg) click to toggle source
# File lib/rumanu/numerology.rb, line 82
  def validate_dob(arg)
    valid_date?(arg)
end
validate_name(arg) click to toggle source
# File lib/rumanu/numerology.rb, line 68
def validate_name(arg)
  raise ArgumentError, 'Name must be a string' unless arg.is_a? String
  raise ArgumentError, "Name can't be blank" if arg.empty?
  unless arg.gsub(/[^A-Za-z ]/, '').empty?
    raise ArgumentError, "Name can't be just numbers or special characters"
  end
end