This post originated from an RSS feed registered with Ruby Buzz
by Jan Lelis.
Original Post: Gem: clipboard
Feed Title: rbJ*_*L.net
Feed URL: http://feeds.feedburner.com/rbJL
Feed Description: Hi, I am a fan of Ruby and like to explore it and the world around ;).
So I started this blog, where I am publishing code snippets, tutorials for beginners as well as general thoughts about Ruby, the web or programming in general.
The clipboard gem allows you to access the clipboard on Liunx, MacOS and Windows.
The focus is on simple text. You can copy a string with Clipboard.copy("string") and paste it with Clipboard.paste. That’s it ;). Basically. Now let’s take a closer look at the specific platforms.
Linux
For Linux support, the little utility xclip is needed, you can install on ubuntu with sudo apt-get install xclip
Furthermore, you can choose, from which clipboard you want to paste (default is PRIMARY). copy copies to all clipboards in Clipboard::CLIPBOARDS. For example: Clipboard.paste :clipboard
MacOS
On MacOS, everything works fine :).
Windows
I’ve fought with the Win32API and still not all problems are solved (e.g. pasting with 1.9). Copying should be no problem, but you need the clip.exe program (installed by default since Vista).