Module: System::Pboard

Defined in:
lib/system_control/pboard.rb

Instance Method Summary collapse

Instance Method Details

#clearObject

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

#copy(string) ⇒ Object

This method sets a string to the pasteboard.

Parameters:

  • string (String)

    The string that sets 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

#pasteString

This method gets a string from the pasteboard.

Returns:

  • (String)

    The string that gets 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

#readString

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

Returns:

  • (String)

    The string that gets from the pasteboard.



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

def read
  self.paste
end

#write(string) ⇒ Object

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

Parameters:

  • string (String)

    The string that sets to the pasteboard.



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

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