Module: Clipboard

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

Overview

Ruby-Gnome2 based implementation Requires either the gtk3 or the gtk2 gem

Defined Under Namespace

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

Constant Summary collapse

VERSION =
"1.3.6"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.implementationObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/clipboard.rb', line 23

def self.implementation
  return @implementation if @implementation

  os = case RbConfig::CONFIG['host_os']
  when /mac|darwin/        then :Mac
  when /linux|bsd/         then :Linux
  when /mswin|mingw/       then :Windows
  when /cygwin/            then :Cygwin
  else
    raise ClipboardLoadError, "Your OS(#{ RbConfig::CONFIG['host_os'] }) is not supported, using file-based (fake) clipboard"
  end

  # Running additional check to detect if running in Microsoft WSL
  if os == :Linux
    require "etc"
    if Etc.respond_to?(:uname) && Etc.uname[:release] =~ /Microsoft/ # uname was added in ruby 2.2
      os = :Wsl
    end
  end

  @implementation = Clipboard.const_get(os)
rescue ClipboardLoadError => e
  $stderr.puts e.message if $VERBOSE
  @implementation = Clipboard::File
end

.implementation=(val) ⇒ Object



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

def self.implementation=(val)
  @implementation = val
end

Instance Method Details

#clear(*args) ⇒ Object



57
58
59
# File 'lib/clipboard.rb', line 57

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

#copy(*args) ⇒ Object



61
62
63
# File 'lib/clipboard.rb', line 61

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

#paste(*args) ⇒ Object



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

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