4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/sinatra/kittens/helpers.rb', line 4
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
|