-
Notifications
You must be signed in to change notification settings - Fork 1
/
ab-timer.exs
66 lines (54 loc) · 1.14 KB
/
ab-timer.exs
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
defmodule AbWorkout do
def say(words) do
IO.puts(words)
System.cmd("say", [words])
end
def sleep(seconds) do
:timer.sleep(seconds * 1000)
end
def get_ready() do
say("Get ready for ab work out. Starting in...")
count(5)
end
def count(count) do
count..1
|> Enum.each(fn(n) ->
n
|> Integer.to_string()
|> say()
sleep(1)
end)
end
def all_done() do
say("You are done!")
end
def exercise({name, time}) do
say("#{name} for #{time} seconds. Go!")
half =
(time / 2)
|> round()
remainder = half - 5
sleep(half)
say("#{half} seconds remaining...")
sleep(remainder)
count(5)
say("Done with #{name}")
end
def workout() do
exercises = [
{"Figure 8s", 60},
{"Windshield Wipers", 60},
{"Twisting Pistons", 60},
{"Rest", 30},
{"Starfish Crunch", 30},
{"Tuck Planks Same Side", 60},
{"Upper Circle Crunches Clockwise", 60},
{"Upper Circle Crunches Counter-Clockwise", 60}
]
get_ready()
exercises
|> Enum.each(&(exercise(&1)))
all_done()
end
end
AbWorkout.workout()