Class: Privacy::Person

Inherits:
Object
  • Object
show all
Defined in:
lib/privacy/person.rb

Constant Summary collapse

COLUMNS_TO_ANONYMIZE =
[
  'Nom _identifier_',
  'Prénom _identifier_',
  'Date de naissance _identifier_',
  'Lieu naissance Pays _identifier_',
  'Lieu naissance Ville _identifier_',
  'Lieu naissance Département _identifier_',
  'Sexe _identifier_',
  'Nationalité _identifier_',
  'Adresse _identifier_ [Date]',
  'Adresse _identifier_ [Département]',
  'Adresse _identifier_ [Ville]',
  'Adresse _identifier_ [Pays]',
  'Profession _identifier_',
  'Date profession _identifier_'
]
INITIALS_SEPARATORS =
[
  '',
  '.'
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifier) ⇒ Person

Returns a new instance of Person.



26
27
28
29
# File 'lib/privacy/person.rb', line 26

def initialize(identifier)
  @identifier = identifier
  puts "Identify #{identifier}"
end

Instance Attribute Details

#columnsObject (readonly)

Returns the value of attribute columns.



2
3
4
# File 'lib/privacy/person.rb', line 2

def columns
  @columns
end

#combinationsObject (readonly)

Returns the value of attribute combinations.



2
3
4
# File 'lib/privacy/person.rb', line 2

def combinations
  @combinations
end

#dataObject (readonly)

Returns the value of attribute data.



2
3
4
# File 'lib/privacy/person.rb', line 2

def data
  @data
end

#identifierObject (readonly)

Returns the value of attribute identifier.



2
3
4
# File 'lib/privacy/person.rb', line 2

def identifier
  @identifier
end

#indexObject (readonly)

Returns the value of attribute index.



2
3
4
# File 'lib/privacy/person.rb', line 2

def index
  @index
end

#initialsObject (readonly)

Returns the value of attribute initials.



2
3
4
# File 'lib/privacy/person.rb', line 2

def initials
  @initials
end

#rowObject (readonly)

Returns the value of attribute row.



2
3
4
# File 'lib/privacy/person.rb', line 2

def row
  @row
end

Instance Method Details

#anonymize(row, index) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/privacy/person.rb', line 45

def anonymize(row, index)
  @row = row
  @index = index + 1 # Excel is 1-indexed
  anonymize_personal_data
  build_combinations
  remove_combinations
end

#identify_columns(row) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/privacy/person.rb', line 31

def identify_columns(row)
  @columns = {}
  row.each do |key, value|
    COLUMNS_TO_ANONYMIZE.each do |column|
      name = column_with_identifier column
      if value == name
        letter = key.gsub '1', ''
        @columns[letter] = name
        puts "  #{name} on column #{letter}"
      end
    end
  end
end