Class: Anon::CSV::Columns

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

Overview

Encapsulates the logic required to choose and format the list of columns to be anonomised

Instance Method Summary collapse

Constructor Details

#initialize(columns, headers) ⇒ Columns

Initialzes a new instance of Columns

Parameters:

  • columns (String)

    the columns to be anonomised, comma seperated may be names or indexes

  • headers (Array<String>)

    the full list of headers



11
12
13
# File 'lib/anon/csv/columns.rb', line 11

def initialize(columns, headers)
  @columns, @headers = columns, headers
end

Instance Method Details

#to_anonymiseArray<String,Integer>

Returns the columns that should be anonomised, if the object was initialized without a predefined list of columns then returns a guess based on the list of headers.

Returns:

  • (Array<String,Integer>)

    the columns to be anonomised, indexes are returned as Integer



18
19
20
# File 'lib/anon/csv/columns.rb', line 18

def to_anonymise
  @_to_anonymise ||= indexes || columns || best_guess
end