@variable ||= computation
pattern.memoized
over the @variable ||=
syntax?Write a class WebsiteSizer
that measures the number of characters in the given URL's HTML body:
website_sizer = WebsiteSizer.new
website_sizer.size_of('https://makandra.com') # => 27448
website_sizer.size_of('https://railslts.com') # => 2145364
You can use any library to perform the actual HTTP request.
The class should cache its results so subsequent calls for the same URLs return the HTML size instantly, without making an additional HTTP request.
Write two versions of WebsiteSizer
:
memoized
gem.