Skip to content

Instantly share code, notes, and snippets.

@lolmaus
Created April 21, 2011 12:15
Show Gist options
  • Save lolmaus/934361 to your computer and use it in GitHub Desktop.
Save lolmaus/934361 to your computer and use it in GitHub Desktop.
class DB_CSV < DB
def initialize
@filepath = File.join(APP_ROOT, Conf[:db_name] + ".csv")
end
def db_accessible?
return true if @filepath &&
File.exists?(@filepath) &&
File.readable?(@filepath) &&
File.writable?(@filepath)
# Конец if
end
def db_init
File.open(@filepath, 'w') unless db_accessible?
return db_accessible?
end
def add(arr)
CSV.open(@@filepath, 'a:UTF-8') do |writer|
writer << arr
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment