How to check the number of unread Gmail messages in my mailbox with a short Ruby script?
Use ruby-gmail
gem install ruby-gmail mime
irb(main):001:0> require 'gmail' => true irb(main):002:0> gmail = Gmail.new("email@gmail.com", "password") => #<Gmail:0x1ea65d8 (email@gmail.com) disconnected> irb(main):004:0> gmail.inbox.count(:unread) => 42
The Nash solution worked for me as soon as I added require 'rubygems'as a first step.
require 'rubygems'
Before that I got the following error when using require 'gmail'.
require 'gmail'
LoadError: no such file to load -- gmail