Module: System::Pboard

Defined in:
lib/system_control/pboard.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) clear

Clears the existing contents of the pasteboard.



44
45
46
47
48
# File 'lib/system_control/pboard.rb', line 44

def clear
  pboard = NSPasteboard.generalPasteboard
  pboard.clearContents
  nil
end

- (Object) copy(string)

This method sets a string to the pasteboard.



29
30
31
32
33
# File 'lib/system_control/pboard.rb', line 29

def copy(string)
  pboard = NSPasteboard.generalPasteboard
  pboard.declareTypes([NSStringPboardType], owner:nil);
  pboard.setString(string.to_s, forType:NSStringPboardType)
end

- (String) paste

This method gets a string from the pasteboard.



11
12
13
14
15
# File 'lib/system_control/pboard.rb', line 11

def paste
  pboard = NSPasteboard.generalPasteboard
  str   = pboard.stringForType(NSStringPboardType)
  str ||= ""
end

- (String) read

This method gets a string from the pasteboard. This method is alias of System::Pboard.paste.



21
22
23
# File 'lib/system_control/pboard.rb', line 21

def read
  self.paste
end

- (Object) write(string)

This method sets a string to the pasteboard. This method is alias of System::Pboard.copy



39
40
41
# File 'lib/system_control/pboard.rb', line 39

def write(string)
  self.copy(string)
end