Class: Anon::CSV

Inherits:
Base
  • Object
show all
Defined in:
lib/anon/csv.rb,
lib/anon/csv/columns.rb

Overview

Replaces the contents of a set of columns in a CSV stream with anonymous e-mails.

Defined Under Namespace

Classes: Columns

Instance Method Summary collapse

Methods inherited from Base

anonymise!

Constructor Details

#initialize(input, output, columns_to_anonymise, has_header = true) ⇒ CSV

Returns a new instance of the CSV anonymiser

Parameters:

  • input (IO, #gets)

    the stream to read from

  • output (IO, #puts)

    the stream to write to

  • columns_to_anonymise (String)

    a comma seperated list of columns to anonymise, if nil we guess

  • has_header (Boolean) (defaults to: true)

    defaults to true



15
16
17
18
19
20
# File 'lib/anon/csv.rb', line 15

def initialize(input, output, columns_to_anonymise, has_header = true)
  @input = input
  @output = output
  @columns_to_anonymise = columns_to_anonymise
  @has_header = has_header
end

Instance Method Details

#anonymise!Object

Anonymises all content of the columns set in the initializer



23
24
25
26
27
28
29
30
31
# File 'lib/anon/csv.rb', line 23

def anonymise!
  start_progress
  map_lines do |line|
    anonymise(line)
    increment_progress
    line
  end
  complete_progress
end