Class: Peanut::Clipboard

Inherits:
Object
  • Object
show all
Defined in:
lib/peanut/clipboard.rb

Class Method Summary collapse

Class Method Details

.copy(string) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/peanut/clipboard.rb', line 5

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

.pasteObject



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

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