Created
December 15, 2014 11:46
-
-
Save syntacticsugar/12bfecc8c7b1877e0f8d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Sinatra | |
module Kittens | |
module Helpers | |
def kittens_page(x = 200..500, factor = 0.2) | |
sample_method = RUBY_VERSION >= '1.9' ? :sample : :choice | |
x = x.to_a.send(sample_method) | |
y = ((x - factor*x).floor..(x + factor*x).ceil).to_a.send(sample_method) | |
<<-HTML | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Not found</title> | |
</head> | |
<body> | |
<center> | |
<h1>Page not found</h2> | |
<img src="http://placekitten.com/#{x}/#{y}" alt="Kitten!" height="#{x}" width="#{y}"> | |
</center> | |
</body> | |
</html> | |
HTML | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment