lib/aruba-doubles/history.rb in aruba-doubles-1.2.0 vs lib/aruba-doubles/history.rb in aruba-doubles-1.2.1
- old
+ new
@@ -22,9 +22,20 @@
def each
entries.each { |e| yield(e) }
end
+ # @return [String] inspection of the entries
+ def to_s
+ to_a.inspect
+ end
+
+ # Return entries just like running `history` in your shell.
+ # @return [String] pretty representation of the entries
+ def to_pretty
+ to_a.each_with_index.map { |e,i| "%5d %s" % [i+1, e.shelljoin] }.join("\n")
+ end
+
private
def entries
@store.transaction(readonly=true) do
@store[:history] || []