Skip to content

Commit 2d5aa95

Browse files
authored
Merge pull request #1 from cadamini/change-everthing
Remove chaotic classes and start over
2 parents 390d141 + edf364a commit 2d5aa95

21 files changed

+26736
-418
lines changed

lib/distribution.rb

Lines changed: 0 additions & 53 deletions
This file was deleted.

lib/export_date_range.rb

Lines changed: 0 additions & 27 deletions
This file was deleted.

lib/input.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Input
2+
attr_reader :year
3+
def initialize
4+
@year = ARGV[0] # ARGV[0].to_i > 0 ? ARGV[0].to_i : Date.today.year
5+
# interval 15
6+
# start Date
7+
# end Date
8+
# region (for holidays) # !ARGV[1].nil? ? ARGV[1] : 'de'
9+
# queue name
10+
# opening hours
11+
end
12+
end

lib/line_builder.rb

Lines changed: 0 additions & 45 deletions
This file was deleted.

lib/normal_distribution.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
require 'distribution'
2+
# http://rubydoc.info/gems/distribution/0.7.0/Distribution/Normal/Ruby_
3+
4+
class NormalDistribution
5+
6+
def initialize
7+
@rng = Distribution::Normal.rng(1, 10) # mean, standard_deviation
8+
end
9+
10+
def day
11+
# returns array with 96 values
12+
13+
random_numbers = Array.new(96).map { @rng.call }
14+
random_numbers.each_with_index { |e, i| random_numbers[i] = (e**2).round }
15+
16+
# find max and delete it from source
17+
sorted_array = []
18+
sorted_array << random_numbers.max
19+
random_numbers.delete_at(random_numbers.index(random_numbers.max))
20+
21+
# loop over remaining values, sorted desc
22+
random_numbers.sort!{ |a, b| b <=> a }.each_with_index do |value, idx|
23+
# slightly randomize values
24+
# value -= rand(0..1) if value == 1
25+
# value > 2 ? value += rand(1..3) : value += 0
26+
27+
# sort values
28+
if idx.even?
29+
sorted_array.unshift(value)
30+
else
31+
sorted_array.push(value)
32+
end
33+
end
34+
35+
sorted_array
36+
end
37+
38+
end

lib/output_generator.rb

Lines changed: 0 additions & 34 deletions
This file was deleted.

lib/output_printer.rb

Lines changed: 0 additions & 25 deletions
This file was deleted.

lib/range.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
require 'date'
2+
3+
class Range
4+
attr_reader :year, :start_date, :end_date
5+
6+
def initialize(year)
7+
@year = year.to_i
8+
end
9+
10+
def start_date
11+
Date.new(year, 1, 1)
12+
end
13+
14+
def end_date
15+
if this_year?(year)
16+
Date.new(year, Date.today.month, Date.today.day)
17+
else
18+
Date.new(year, 12, 31)
19+
end
20+
end
21+
22+
private
23+
24+
def this_year?(year)
25+
year == Date.today.year
26+
end
27+
end
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
class TimeStringBuilder
2-
def self.create_for(minutes)
1+
class TimeFormatter
2+
def self.convert_minutes(minutes)
33
hours = minutes / 60
44
time = Time.new(2001, 1, 1, hours, minutes % 60, 0)
55
time.strftime('%H:%M')

lib/value_randomizer.rb

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)