Sha256: 901b6899b18ac48c0df02fa80c95ac6714fb16d7a530874d485b349d5b831da0

Contents?: true

Size: 1020 Bytes

Versions: 10

Compression:

Stored size: 1020 Bytes

Contents

require 'roo'

#-- create a new spreadsheet within your google-spreadsheets and paste
#-- the 'key' parameter in the spreadsheet URL
MAXTRIES = 1000
print "what's your name? "
my_name = gets.chomp
print "where do you live? "
my_location = gets.chomp
print "your message? (if left blank, only your name and location will be inserted) "
my_message = gets.chomp
spreadsheet = Google.new('ptu6bbahNZpY0N0RrxQbWdw')
spreadsheet.default_sheet = 'Sheet1'
success = false
MAXTRIES.times do
  col = rand(10)+1
  row = rand(10)+1
  if spreadsheet.empty?(row,col)
    if my_message.empty?
      text = Time.now.to_s+" "+"Greetings from #{my_name} (#{my_location})"
    else
      text = Time.now.to_s+" "+"#{my_message} from #{my_name} (#{my_location})"
    end
    spreadsheet.set_value(row,col,text)
    puts "message written to row #{row}, column #{col}"
    success = true
    break
  end
  puts "Row #{row}, column #{col} already occupied, trying again..."
end
puts "no empty cell found within #{MAXTRIES} tries" if !success

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
shoppe-paypal-1.1.0 vendor/bundle/ruby/2.1.0/gems/roo-1.13.2/examples/write_me.rb
roo-1.13.2 examples/write_me.rb
roo-1.13.1 examples/write_me.rb
roo-1.13.0 examples/write_me.rb
roo-1.12.2 examples/write_me.rb
roo-1.12.1 examples/write_me.rb
roo-1.12.0 examples/write_me.rb
roo-1.11.2 examples/write_me.rb
roo-1.11.1 examples/write_me.rb
roo-1.11.0 examples/write_me.rb