Module: Zap::Clipboard

Defined in:
lib/zap/clipboard.rb

Class Method Summary collapse

Class Method Details

.copy(string) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/zap/clipboard.rb', line 3

def self.copy(string)
  
  cmd = if RUBY_PLATFORM =~ /linux/
    "xclip -selection clipboard"
  else
    "pbcopy"
  end
  
  `echo #{string} | tr -d "\n" | #{cmd}`        
end

.pasteObject



14
15
16
17
18
19
20
# File 'lib/zap/clipboard.rb', line 14

def self.paste
  if RUBY_PLATFORM =~ /darwin/
    `pbpaste`
  else
    `xclip -selection clipboard -o`
  end
end