Sha256: 6cdde1ea90173985dee54d90ee7cb2d20be61a505782f9795eef09c660155112
Contents?: true
Size: 883 Bytes
Versions: 1
Compression:
Stored size: 883 Bytes
Contents
require 'csv' module ErrandBoy class CSV class Base def initialize(request) @request = request end def push write_header unless File.exist?(path) File.open path, 'a' do |f| f.puts values end end def include?(key, value) ::CSV.table(path).by_col[key].include?(value) end def path File.join CSV.dir, filename end def filename "#{@request.provider}_#{@request.action}.csv" end def headers raise NotImplementedError, 'Subclass must implement this method!' end def values raise NotImplementedError, 'Subclass must implement this method!' end private def write_header File.write path, headers rescue Errno::ENOENT Dir.mkdir CSV.dir retry end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
errand-boy-0.1.0 | lib/errand_boy/csv/base.rb |