Module: Clipboard

Extended by:
Clipboard
Included in:
Clipboard
Defined in:
lib/clipboard.rb,
lib/clipboard/gtk.rb,
lib/clipboard/mac.rb,
lib/clipboard/wsl.rb,
lib/clipboard/file.rb,
lib/clipboard/java.rb,
lib/clipboard/linux.rb,
lib/clipboard/osc52.rb,
lib/clipboard/utils.rb,
lib/clipboard/cygwin.rb,
lib/clipboard/version.rb,
lib/clipboard/windows.rb,
lib/clipboard/linux_wayland.rb,
lib/clipboard/implementation.rb,
lib/clipboard/clipboard_load_error.rb

Defined Under Namespace

Modules: Cygwin, File, Gtk, Implementation, Java, Linux, LinuxWayland, Mac, Osc52, Utils, Windows, Wsl Classes: ClipboardLoadError

Constant Summary collapse

VERSION =
"2.0.0"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.implementationObject



23
24
25
26
27
28
29
30
# File 'lib/clipboard.rb', line 23

def self.implementation
  return @implementation if @implementation

  @implementation = Clipboard.const_get(Utils.autodetect_implementation)
rescue ClipboardLoadError, NameError => e
  $stderr.puts "#{e.message}\nUsing file-based (fake) clipboard" unless $VERBOSE == nil
  @implementation = Clipboard::File
end

.implementation=(implementation) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/clipboard.rb', line 32

def self.implementation=(implementation)
  if !implementation
    @implementation = nil
  elsif implementation.is_a? Module
    @implementation = implementation
  else
    camel_cased_implementation_name = implementation.to_s.gsub(/(?:^|_)([a-z])/) do $1.upcase end
    @implementation = Clipboard.const_get(camel_cased_implementation_name)
  end
rescue ClipboardLoadError, NameError => e
  $stderr.puts "#{e.message}\nUsing file-based (fake) clipboard" unless $VERBOSE == nil
  @implementation = Clipboard::File
end

Instance Method Details

#clearObject



50
51
52
# File 'lib/clipboard.rb', line 50

def clear(...)
  Clipboard.implementation.clear(...)
end

#copyObject



54
55
56
# File 'lib/clipboard.rb', line 54

def copy(...)
  Clipboard.implementation.copy(...)
end

#pasteObject



46
47
48
# File 'lib/clipboard.rb', line 46

def paste(...)
  Clipboard.implementation.paste(...)
end