# File lib/cheat.rb, line 38 def fetch_sheet(uri, try_to_cache = true) open(uri, headers) do |body| sheet = body.read FileUtils.mkdir_p(cache_dir) unless File.exists?(cache_dir) File.open(cache_file, 'w') { |f| f.write(sheet) } if try_to_cache && has_content(sheet) && cache_file && !@edit @edit ? edit(sheet) : show(sheet) end exit rescue OpenURI::HTTPError => e puts "Whoa, some kind of Internets error!", "=> #{e} from #{uri}" end