class Kitchen::Clipboard
A place to store lists of things during recipe work. Essentially a slightly fancy array.
Public Class Methods
new()
click to toggle source
Creates a new Clipboard
# File lib/kitchen/clipboard.rb, line 19 def initialize clear end
Public Instance Methods
add(item)
click to toggle source
Add an element to the clipboard
@param item [ElementBase]
# File lib/kitchen/clipboard.rb, line 27 def add(item) @items.push(item) self end
clear()
click to toggle source
Clears the clipboard
# File lib/kitchen/clipboard.rb, line 34 def clear @items = [] self end
each(&block)
click to toggle source
Iterates over each item on the clipboard @yield each item @return [Clipboard] self
# File lib/kitchen/clipboard.rb, line 50 def each(&block) if block_given? @items.each do |item| block.call(item) end end self end
items()
click to toggle source
The underlying array @return [Array<ElementBase>]
# File lib/kitchen/clipboard.rb, line 13 def items @items.clone end
paste()
click to toggle source
Returns a concatenation of the pasting of each item on the clipboard @return [String]
# File lib/kitchen/clipboard.rb, line 42 def paste @items.map(&:paste).join('') end
sort_by!(&block)
click to toggle source
Sorts the clipboard using the provided block @yield each item @return [Clipboard] self
# File lib/kitchen/clipboard.rb, line 63 def sort_by!(&block) @items.sort_by!(&block) self end