Module: Clipboard

Extended by:
Clipboard
Included in:
Clipboard
Defined in:
lib/clipboard.rb,
lib/clipboard/mac.rb,
lib/clipboard/file.rb,
lib/clipboard/linux.rb,
lib/clipboard/windows.rb

Defined Under Namespace

Modules: File, Linux, Mac, Windows Classes: ClipboardLoadError

Constant Summary collapse

VERSION =
File.read( (File.dirname(__FILE__) + '/../VERSION') ).chomp

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.implementationObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/clipboard.rb', line 14

def self.implementation
return @implementation if @implementation

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

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

.implementation=(val) ⇒ Object



32
33
34
# File 'lib/clipboard.rb', line 32

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

Instance Method Details

#clear(*args) ⇒ Object



40
41
42
# File 'lib/clipboard.rb', line 40

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

#copy(*args) ⇒ Object



44
45
46
# File 'lib/clipboard.rb', line 44

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

#paste(*args) ⇒ Object



36
37
38
# File 'lib/clipboard.rb', line 36

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