class Diakonos::ClipboardOSX
Same interface as Diakonos::Clipboard
, except interacts with pbcopy and pbpaste on OSX
Public Class Methods
new()
click to toggle source
# File lib/diakonos/clipboard-osx.rb, line 7 def initialize end
Public Instance Methods
add_clip(text)
click to toggle source
@param [Array<String>] text @return true iff a clip was added
# File lib/diakonos/clipboard-osx.rb, line 37 def add_clip(text) send_to_pbcopy text end
append_to_clip(text)
click to toggle source
@param [Array<String>] lines of text Appends the lines to the current clip. If no current clip, then a new clip is created. @return true iff the text was successfully appended
# File lib/diakonos/clipboard-osx.rb, line 49 def append_to_clip(text) return false if text.nil? last_clip = clip last_clip.pop if last_clip[-1] == "" send_to_pbcopy last_clip + text end
clip()
click to toggle source
# File lib/diakonos/clipboard-osx.rb, line 31 def clip `pbpaste`.split( "\n", -1 ) end
each()
click to toggle source
no-op
# File lib/diakonos/clipboard-osx.rb, line 42 def each end
send_to_pbcopy(text)
click to toggle source
@return true iff some text was copied to pbcopy
# File lib/diakonos/clipboard-osx.rb, line 11 def send_to_pbcopy(text) return false if text.nil? clip_filename = write_to_clip_file( text.join( "\n" ) ) `pbcopy < #{clip_filename}` true end
write_to_clip_file(text)
click to toggle source
TODO: DRY this up with other Clipboard
classes
# File lib/diakonos/clipboard-osx.rb, line 21 def write_to_clip_file(text) clip_filename = $diakonos.diakonos_home + "/clip.txt" File.open( clip_filename, "w" ) do |f| f.print text end clip_filename end