xclip in a few lines of ruby

Update: I happened to check the source code of the 'clipboard' gem and it turns out that it depends on xclip. So the code below is just nonsense.

An xclip in a few lines of ruby

#!/usr/bin/env ruby

require 'clipboard'

if ARGV.empty?
  Clipboard.copy ARGF.readlines.join("\n")
else
  Clipboard.copy ARGV.join(' ')
end

Use cases

#copy the html source of cosmicvent.com to clipboard
curl -s http://cosmicvent.com | xc 

#copy date to clipboard
xc $(date)
#xclip #ruby #utility