-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexamples.rb
More file actions
50 lines (44 loc) · 756 Bytes
/
examples.rb
File metadata and controls
50 lines (44 loc) · 756 Bytes
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
require 'ke'
# Simplest usage, no arguments.
Ke.job do |job|
50.times do
job.tick do
sleep 0.1
end
end
end
# Set a specific reporter.
Ke.job(reporter: Ke::MultiLineReporter) do |job|
50.times do
job.tick do
sleep 0.1
end
end
end
# Set the total number of ticks, so we use DeterminateTask and get a time remaining estimates.
Ke.job(50) do |job|
50.times do
job.tick do
sleep 0.1
end
end
end
# Report progress every 10 ticks.
Ke.job(report_every: 10) do |job|
50.times do
job.tick do
sleep 0.1
end
end
end
# Report to a file.
File.open("log.txt", "w") do |f|
f.sync = true
Ke.job(io: f) do |job|
50.times do
job.tick do
sleep 0.1
end
end
end
end