Module: AliyunExmailCSVGenerator::Exporter

Defined in:
lib/aliyun_exmail_csv_generator/exporter.rb

Class Method Summary collapse

Class Method Details

.accounts_to_csv(accounts, filepath) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/aliyun_exmail_csv_generator/exporter.rb', line 8

def accounts_to_csv(accounts, filepath)
  filepath = File.absolute_path(File.expand_path(filepath))
  filedir = File.dirname filepath
  FileUtils.mkdir_p filedir unless File.exist? filedir
  CSV.open(filepath, 'w:GB2312') do |csv|
    csv << ["#姓名", "邮件地址", "工号", "密码", "部门", "分机", "职称", "手机号", "容量"]
    accounts.each do ||
      csv << .to_csv_row
    end
  end
  filepath
end