class Diakonos::Clipboard
Public Class Methods
new( max_clips )
click to toggle source
# File lib/diakonos/clipboard.rb, line 4 def initialize( max_clips ) @clips = Array.new @max_clips = max_clips end
Public Instance Methods
[]( arg )
click to toggle source
# File lib/diakonos/clipboard.rb, line 9 def [] ( arg ) @clips[ arg ] end
add_clip( text )
click to toggle source
text is an array of Strings Returns true iff a clip was added, and only non-nil text can be added.
# File lib/diakonos/clipboard.rb, line 20 def add_clip( text ) return false if text.nil? @clips.unshift text @clips.pop if @clips.length > @max_clips true end
append_to_clip( text )
click to toggle source
text is an array of Strings (lines) Appends the lines to the current clip. If no current clip, then a new clip is created. Returns true iff the text was successfully appended.
# File lib/diakonos/clipboard.rb, line 37 def append_to_clip( text ) return false if text.nil? return add_clip( text ) if @clips.length == 0 last_clip = @clips[ 0 ] last_clip.pop if last_clip[ -1 ] == "" @clips[ 0 ] = last_clip + text true end
clip()
click to toggle source
# File lib/diakonos/clipboard.rb, line 13 def clip @clips[ 0 ] end
each() { |clip| ... }
click to toggle source
# File lib/diakonos/clipboard.rb, line 27 def each @clips.each do |clip| yield clip end end