-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmy_app.rb
40 lines (34 loc) · 855 Bytes
/
my_app.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# my_app.#!/usr/bin/env ruby -wKU
require 'sinatra'
require 'date'
class MyApp < Sinatra::Base
date = DateTime.new
# This is where your code will go
def time_of_day()
t = Time.now
if t.hour >= 4 and t.hour < 10
return "morning"
elsif t.hour >= 10 and t.hour < 16
return "midday"
elsif t.hour >= 16 or t.hour < 4
return "bedtime"
else
return "late"
end
end
# a date prettifier
def pretty_date()
months = ["Zeroth", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
t = DateTime.now
return "#{months[t.month]} #{t.day}, #{t.year}"
end
get "/" do
erb :basic_index
end
get "/animals" do
erb :animals
end
get "/basic" do
erb :basic
end
end