-
Notifications
You must be signed in to change notification settings - Fork 3
/
Rakefile
43 lines (35 loc) · 881 Bytes
/
Rakefile
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
# frozen_string_literal: true
require 'bundler/gem_tasks'
require 'rake/testtask'
Rake::TestTask.new(:test) do |t|
t.libs << 'test'
t.libs << 'lib'
t.test_files = FileList['test/**/*_test.rb']
end
task default: :test
namespace :sample do
require 'ascii_chart'
desc 'Out put a random case'
task :random do
sample = Random.rand(3)
Rake::Task["sample:#{sample + 1}"].invoke
end
desc 'Output the first case'
task :'1' do
puts AsciiChart.plot((0...90).map do |i|
Math.cos(i * ((Math::PI * 4) / 90)).round(2) * 5
end)
end
desc 'Output the second case'
task :'2' do
puts AsciiChart.plot((0...90).map do |i|
Math.cos(i * ((Math::PI * 8) / 90)).round(2) * 10
end)
end
desc 'Output the third case'
task :'3' do
puts AsciiChart.plot(Array.new(90) do
Random.rand(10) * (-1)**Random.rand(2)
end)
end
end