Module: Clipboard::File

Extended by:
File
Included in:
File
Defined in:
lib/clipboard/file.rb

Constant Summary collapse

FILE =
::File.expand_path("~/.clipboard")

Instance Method Summary collapse

Instance Method Details

#clearObject



18
19
20
# File 'lib/clipboard/file.rb', line 18

def clear
  copy ''
end

#copy(text) ⇒ Object



9
10
11
12
# File 'lib/clipboard/file.rb', line 9

def copy(text)
  ::File.open(FILE, 'w', 0o0600) { |f| f.write(text) } rescue ''
  paste
end

#paste(_ = nil) ⇒ Object



14
15
16
# File 'lib/clipboard/file.rb', line 14

def paste(_ = nil)
  ::File.read(FILE) rescue ''
end