class Scruber::Helpers::DictionaryReader::Csv
Public Class Methods
new(file_path)
click to toggle source
# File lib/scruber/helpers/dictionary_reader/csv.rb, line 5 def initialize(file_path) @file_path = file_path end
Public Instance Methods
read(options={}) { |csv_row| ... }
click to toggle source
# File lib/scruber/helpers/dictionary_reader/csv.rb, line 9 def read(options={}) col_sep = options.delete(:col_sep) || ',' CSV.foreach(@file_path, col_sep: col_sep, headers: true, encoding: 'utf-8') do |csv_row| if options.blank? yield csv_row else if options.all?{|(k,v)| csv_row[k.to_s] == v } yield csv_row end end end end