Top Level Namespace
Instance Method Summary collapse
Instance Method Details
#copy(obj) ⇒ Object
4 5 6 7 |
# File 'lib/copyrb.rb', line 4 def copy(obj) text = Base64.encode64(YAML.dump(obj)).gsub("\n", '') # getting rid of meaningless new lines IO.popen('pbcopy', 'r+') { |clipboard| clipboard.puts text } end |
#paste ⇒ Object
9 10 11 12 |
# File 'lib/copyrb.rb', line 9 def paste text = IO.popen('pbpaste', 'r+') { |clipboard| clipboard.gets } YAML.load(Base64.decode64(text)) end |