Skip to content

Instantly share code, notes, and snippets.

require 'ray'
class LazyObject < BasicObject
def initialize(&callback)
@callback = callback
end
def __result__
@__result__ ||= @callback.call
end
class DownloadManager
def initialize
@downloads = []
end
def save(url, filename)
downloads << Lazy.future { File.binwrite(filename, open(url).read) }
end
def finish_all_downloads
set nobackup
set nowritebackup
set noswapfile
set backspace=indent,eol,start
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
[:id, :season, :episode].all? { |k| options.key?(k) }
raise ArgumentError, ":id, :season, and :episode are required"
end
# From Bryan Liles on the Practicing Ruby Discussion List
1. TDD is a great tool. As a tool, you'll use it when appropriate.
TATFT mostly means that you should be thinking about how you can put
whatever you are creating under test at all times. Writing tests for
the sake of writing tests is silly.
2. Like Gregory stated, brittle tests aren't helping anyone. Think
about the ingress/egress points of your objects at all times.