Sha256: 076fe6c19369978c13ee50e6c6a87fb9b87e0ddd3ab31fe4a4858b4b51b8dfb2

Contents?: true

Size: 691 Bytes

Versions: 9

Compression:

Stored size: 691 Bytes

Contents

$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$:.unshift(File.dirname(__FILE__))
require 'rubygems'
require 'ncmb'
require 'yaml'
require 'csv'

yaml = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'setting.yml'))
NCMB.initialize application_key: yaml['application_key'],  client_key: yaml['client_key']
@todo = NCMB::DataStore.new 'TestClass'
1000.times do |i|
  @todo.post(message: "Hello! #{i}")
end
@todos = @todo.limit(20).count(1).skip(0)

csv_string = CSV.generate do |csv|
  csv << @todos.first.columns
  @todos.each do |todo|
    params = []
    todo.columns.each do |name|
      params << todo.call(name)
    end
    csv << params
  end
end

puts csv_string

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ncmb-ruby-client-0.1.3 examples/csv_test.rb
ncmb-ruby-client-0.1.2 examples/csv_test.rb
ncmb-ruby-client-0.1.1 examples/csv_test.rb
ncmb-ruby-client-0.1.0 examples/csv_test.rb
ncmb-ruby-client-0.0.9 examples/csv_test.rb
ncmb-ruby-client-0.0.8 examples/csv_test.rb
ncmb-ruby-client-0.0.6 examples/csv_test.rb
ncmb-ruby-client-0.0.5 examples/csv_test.rb
ncmb-ruby-client-0.0.4 examples/csv_test.rb