Sha256: 91e05cacb0448621576cd574825614f9d70b244b00e66c1787a14ae7af4a957f

Contents?: true

Size: 1.02 KB

Versions: 32

Compression:

Stored size: 1.02 KB

Contents

require 'rubygems'
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

32 entries across 32 versions & 5 rubygems

Version Path
jagthedrummer-roo-1.3.12 examples/write_me.rb
roo-1.10.3 examples/write_me.rb
roo-1.10.2 examples/write_me.rb
roo-immersion-1.0.0 examples/write_me.rb
donibuchanan-roo-1.9.1.6 examples/write_me.rb
donibuchanan-roo-1.9.1.5 examples/write_me.rb
aunderwo-roo-1.1.2 examples/write_me.rb
aunderwo-roo-1.1.1 examples/write_me.rb
aunderwo-roo-1.1.0 examples/write_me.rb
donibuchanan-roo-1.9.1.4 examples/write_me.rb
donibuchanan-roo-1.3.12 examples/write_me.rb
aunderwo-roo-1.0.0 examples/write_me.rb
roo-1.3.11 examples/write_me.rb
roo-0.8.0 examples/write_me.rb
roo-0.8.4 examples/write_me.rb
roo-0.8.2 examples/write_me.rb
roo-0.8.3 examples/write_me.rb
roo-0.8.1 examples/write_me.rb
roo-0.9.3 examples/write_me.rb
roo-0.8.5 examples/write_me.rb