24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/patty/server.rb', line 24
def timeline
from = params[:from]
to = params[:to]
step = params[:step].to_sym
unless TIMELINE_STEPS.keys.include?(step)
raise ArgumentError, "invalid step #{step} for timeline"
end
from_datetime = Patty::TimeSignature.new(from).to_datetime
to_datetime = Patty::TimeSignature.new(to).to_datetime
from_datetime.step(to_datetime, TIMELINE_STEPS[step]).map do |s|
current_step = Patty::TimeSignature.from_datetime(s)
if step == :minute
current_step
else
current_step.parents[TIMELINE_MEASURES.index(step)]
end
end
end
|