Class: Clienteer::Sanitizer::Name

Inherits:
Object
  • Object
show all
Defined in:
lib/clienteer/sanitizers/name.rb

Instance Method Summary collapse

Instance Method Details

#process(row) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/clienteer/sanitizers/name.rb', line 6

def process(row)
  names = [row[:raw].first_name, row[:raw].last_name].compact
  if names.length == 1 && names[0].include?(" ")
    names = names[0].split(" ")
    row[:raw].first_name, row[:raw].last_name = *names
  end
  return row if names.all? {|n| proper? n }
  return remove(row)
end

#proper?(name) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/clienteer/sanitizers/name.rb', line 16

def proper?(name)
  !name.match /\d/
end

#remove(row) ⇒ Object



20
21
22
23
24
# File 'lib/clienteer/sanitizers/name.rb', line 20

def remove(row)
  row[:reason] = "names not valid"
  $skipped_people << row
  nil
end