Class: Decidim::FileAuthorizationHandler::CsvData

Inherits:
Object
  • Object
show all
Defined in:
app/models/decidim/file_authorization_handler/csv_data.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ CsvData

Returns a new instance of CsvData.



13
14
15
16
17
18
19
20
21
22
23
# File 'app/models/decidim/file_authorization_handler/csv_data.rb', line 13

def initialize(file)
  @file = file
  @errors = []
  @values = []

  Rails.logger.info "CsvData.col_sep: #{CsvData.col_sep}"
  CSV.foreach(@file, headers: true, col_sep: CsvData.col_sep) do |row|
    @headers = row.headers
    process_row(row)
  end
end

Class Attribute Details

.col_sepObject

Returns the value of attribute col_sep.



9
10
11
# File 'app/models/decidim/file_authorization_handler/csv_data.rb', line 9

def col_sep
  @col_sep
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



11
12
13
# File 'app/models/decidim/file_authorization_handler/csv_data.rb', line 11

def errors
  @errors
end

#headersObject (readonly)

Returns the value of attribute headers.



11
12
13
# File 'app/models/decidim/file_authorization_handler/csv_data.rb', line 11

def headers
  @headers
end

#valuesObject (readonly)

Returns the value of attribute values.



11
12
13
# File 'app/models/decidim/file_authorization_handler/csv_data.rb', line 11

def values
  @values
end