Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Show random idiom on desktop using GeekTool
srand # seed random
require 'csv'
wordArray = Array.new
definitionArray = Array.new
if File.exists?("/Users/zettt/Archive/Vocab/idioms.csv")
CSV.open('/Users/zettt/Archive/Vocab/idioms.csv', 'r') do |row|
# p row[1]
wordArray = wordArray.push(row[0])
definitionArray = definitionArray.push(row[1])
end
else
puts "csv file not found. Ending process."
Process.exit
end
randomLine = rand(wordArray.length)
puts "Idioms"
puts "Word: " + wordArray[randomLine]
puts "Definition: " + definitionArray[randomLine]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment