musa-dsl 0.23.11 → 0.23.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/lib/musa-dsl/datasets/gdv.rb +2 -2
  3. data/lib/musa-dsl/datasets/gdvd.rb +2 -1
  4. data/lib/musa-dsl/datasets/helper.rb +1 -1
  5. data/lib/musa-dsl/datasets/score/queriable.rb +43 -42
  6. data/lib/musa-dsl/datasets/score/render.rb +24 -20
  7. data/lib/musa-dsl/datasets/score/to-mxml/to-mxml.rb +120 -122
  8. data/lib/musa-dsl/generative/backboner.rb +2 -2
  9. data/lib/musa-dsl/generative/generative-grammar.rb +2 -0
  10. data/lib/musa-dsl/generative/markov.rb +1 -2
  11. data/lib/musa-dsl/generative/variatio.rb +6 -10
  12. data/lib/musa-dsl/logger/logger.rb +22 -22
  13. data/lib/musa-dsl/matrix/matrix.rb +3 -5
  14. data/lib/musa-dsl/midi/midi-recorder.rb +3 -4
  15. data/lib/musa-dsl/midi/midi-voices.rb +3 -3
  16. data/lib/musa-dsl/music/chords.rb +26 -29
  17. data/lib/musa-dsl/musicxml/builder/direction.rb +2 -2
  18. data/lib/musa-dsl/neumalang/neumalang.rb +25 -67
  19. data/lib/musa-dsl/neumas/array-to-neumas.rb +2 -2
  20. data/lib/musa-dsl/repl/repl.rb +1 -1
  21. data/lib/musa-dsl/sequencer/base-sequencer-implementation-every.rb +8 -8
  22. data/lib/musa-dsl/sequencer/base-sequencer-implementation-move.rb +49 -49
  23. data/lib/musa-dsl/sequencer/base-sequencer-implementation-play-helper.rb +2 -2
  24. data/lib/musa-dsl/sequencer/base-sequencer-implementation-play-timed.rb +2 -2
  25. data/lib/musa-dsl/sequencer/base-sequencer-implementation-play.rb +2 -2
  26. data/lib/musa-dsl/sequencer/base-sequencer-implementation.rb +2 -2
  27. data/lib/musa-dsl/sequencer/base-sequencer-tick-based.rb +4 -3
  28. data/lib/musa-dsl/sequencer/base-sequencer.rb +5 -5
  29. data/lib/musa-dsl/series/array-to-serie.rb +5 -3
  30. data/lib/musa-dsl/series/base-series.rb +2 -2
  31. data/lib/musa-dsl/series/buffer-serie.rb +0 -5
  32. data/lib/musa-dsl/series/main-serie-constructors.rb +6 -4
  33. data/lib/musa-dsl/series/main-serie-operations.rb +2 -2
  34. data/lib/musa-dsl/series/quantizer-serie.rb +46 -50
  35. data/lib/musa-dsl/series/series-composer.rb +6 -5
  36. data/lib/musa-dsl/series/timed-serie.rb +49 -48
  37. data/lib/musa-dsl/transcription/from-gdv-to-midi.rb +5 -7
  38. data/lib/musa-dsl/transcription/from-gdv-to-musicxml.rb +1 -4
  39. data/lib/musa-dsl/transcription/from-gdv.rb +1 -3
  40. data/lib/musa-dsl/transcription/transcription.rb +2 -4
  41. data/lib/musa-dsl/transport/input-midi-clock.rb +7 -4
  42. data/lib/musa-dsl/transport/transport.rb +10 -12
  43. data/lib/musa-dsl.rb +1 -1
  44. data/musa-dsl.gemspec +2 -2
  45. metadata +2 -2
@@ -7,7 +7,7 @@ module Musa
7
7
  refine Array do
8
8
  def to_neumas
9
9
  if length > 1
10
- MERGE(*collect { |e| convert_to_neumas(e) })
10
+ Musa::Series::Constructors.MERGE(*collect { |e| convert_to_neumas(e) })
11
11
  else
12
12
  convert_to_neumas(first)
13
13
  end
@@ -21,7 +21,7 @@ module Musa
21
21
  def convert_to_neumas(e)
22
22
  case e
23
23
  when Musa::Neumas::Neuma::Serie then e
24
- when Musa::Neumas::Neuma::Parallel then S(e).extend(Musa::Neumas::Neuma::Serie)
24
+ when Musa::Neumas::Neuma::Parallel then Musa::Series::Constructors.S(e).extend(Musa::Neumas::Neuma::Serie)
25
25
  when String then e.to_neumas
26
26
  else
27
27
  raise ArgumentError, "Don't know how to convert to neumas #{e}"
@@ -13,7 +13,7 @@ module Musa
13
13
  @block_source = nil
14
14
 
15
15
  if binder.receiver.respond_to?(:sequencer) &&
16
- binder.receiver.sequencer.respond_to?(:on_error)
16
+ binder.receiver.sequencer.respond_to?(:on_error)
17
17
 
18
18
  binder.receiver.sequencer.on_error do |e|
19
19
  send_exception e, output: @connection
@@ -10,8 +10,9 @@ module Musa::Sequencer
10
10
  control._start_position ||= position
11
11
  control._execution_counter ||= 0
12
12
 
13
- duration_exceeded =
14
- (control._start_position + control.duration_value - interval) <= position if interval && control.duration_value
13
+ if interval && control.duration_value
14
+ duration_exceeded = (control._start_position + control.duration_value - interval) <= position
15
+ end
15
16
 
16
17
  till_exceeded = control.till_value - interval <= position if interval && control.till_value
17
18
 
@@ -23,17 +24,16 @@ module Musa::Sequencer
23
24
  end
24
25
 
25
26
 
26
- unless control.stopped? || duration_exceeded || till_exceeded || condition_failed || interval.nil?
27
- _numeric_at control._start_position + control._execution_counter * interval, control do
28
- _every interval, control, block_procedure_binder: block_procedure_binder
29
- end
30
-
31
- else
27
+ if control.stopped? || duration_exceeded || till_exceeded || condition_failed || interval.nil?
32
28
  control.do_on_stop.each(&:call)
33
29
 
34
30
  control.do_after.each do |do_after|
35
31
  _numeric_at position + (interval || 0) + do_after[:bars], control, &do_after[:block]
36
32
  end
33
+ else
34
+ _numeric_at control._start_position + control._execution_counter * interval, control do
35
+ _every interval, control, block_procedure_binder: block_procedure_binder
36
+ end
37
37
  end
38
38
  end
39
39
 
@@ -1,11 +1,11 @@
1
1
  require_relative '../core-ext/arrayfy'
2
2
  require_relative '../core-ext/inspect-nice'
3
3
 
4
- using Musa::Extension::Arrayfy
5
- using Musa::Extension::InspectNice
6
-
7
4
  module Musa::Sequencer
8
5
  class BaseSequencer
6
+ using Musa::Extension::Arrayfy
7
+ using Musa::Extension::InspectNice
8
+
9
9
  private def _move(every: nil,
10
10
  from:, to: nil,
11
11
  step: nil,
@@ -110,11 +110,11 @@ module Musa::Sequencer
110
110
  steps = (to[i] - from[i]) / step[i]
111
111
 
112
112
  # When to == from don't need to do any iteration with every
113
- if steps + right_open_offset[i] > 0
114
- every[i] = Rational(effective_duration, steps + right_open_offset[i])
115
- else
116
- every[i] = nil
117
- end
113
+ every[i] = if steps + right_open_offset[i] > 0
114
+ Rational(effective_duration, steps + right_open_offset[i])
115
+ else
116
+ nil
117
+ end
118
118
 
119
119
  elsif to[i] && !step[i] && !every[i]
120
120
 
@@ -167,7 +167,7 @@ module Musa::Sequencer
167
167
  #
168
168
  # Prepare yield block, parameters to yield block and coincident moving interval groups
169
169
  #
170
- binder = SmartProcBinder.new(block)
170
+ binder = Musa::Extension::SmartProcBinder::SmartProcBinder.new(block)
171
171
 
172
172
  every_groups = {}
173
173
  group_counter = {}
@@ -300,46 +300,46 @@ module Musa::Sequencer
300
300
  # Adapt values to array/hash/value mode
301
301
  #
302
302
  value_parameters, key_parameters =
303
- if array_mode
304
- binder.apply(effective_values, effective_next_values,
305
- control: control,
306
- duration: _durations(every_groups, effective_duration),
307
- quantized_duration: q_durations.dup,
308
- started_ago: _started_ago(last_position, position, process_indexes),
309
- position_jitter: position_jitters.dup,
310
- duration_jitter: duration_jitters.dup,
311
- right_open: right_open.dup)
312
- elsif hash_mode
313
- binder.apply(_hash_from_keys_and_values(hash_keys, effective_values),
314
- _hash_from_keys_and_values(hash_keys, effective_next_values),
315
- control: control,
316
- duration: _hash_from_keys_and_values(
317
- hash_keys,
318
- _durations(every_groups, effective_duration)),
319
- quantized_duration: _hash_from_keys_and_values(
320
- hash_keys,
321
- q_durations),
322
- started_ago: _hash_from_keys_and_values(
323
- hash_keys,
324
- _started_ago(last_position, position, process_indexes)),
325
- position_jitter: _hash_from_keys_and_values(
326
- hash_keys,
327
- position_jitters),
328
- duration_jitter: _hash_from_keys_and_values(
329
- hash_keys,
330
- duration_jitters),
331
- right_open: _hash_from_keys_and_values(hash_keys, right_open))
332
- else
333
- binder.apply(effective_values.first,
334
- effective_next_values.first,
335
- control: control,
336
- duration: _durations(every_groups, effective_duration).first,
337
- quantized_duration: q_durations.first,
338
- position_jitter: position_jitters.first,
339
- duration_jitter: duration_jitters.first,
340
- started_ago: nil,
341
- right_open: right_open.first)
342
- end
303
+ if array_mode
304
+ binder.apply(effective_values, effective_next_values,
305
+ control: control,
306
+ duration: _durations(every_groups, effective_duration),
307
+ quantized_duration: q_durations.dup,
308
+ started_ago: _started_ago(last_position, position, process_indexes),
309
+ position_jitter: position_jitters.dup,
310
+ duration_jitter: duration_jitters.dup,
311
+ right_open: right_open.dup)
312
+ elsif hash_mode
313
+ binder.apply(_hash_from_keys_and_values(hash_keys, effective_values),
314
+ _hash_from_keys_and_values(hash_keys, effective_next_values),
315
+ control: control,
316
+ duration: _hash_from_keys_and_values(
317
+ hash_keys,
318
+ _durations(every_groups, effective_duration)),
319
+ quantized_duration: _hash_from_keys_and_values(
320
+ hash_keys,
321
+ q_durations),
322
+ started_ago: _hash_from_keys_and_values(
323
+ hash_keys,
324
+ _started_ago(last_position, position, process_indexes)),
325
+ position_jitter: _hash_from_keys_and_values(
326
+ hash_keys,
327
+ position_jitters),
328
+ duration_jitter: _hash_from_keys_and_values(
329
+ hash_keys,
330
+ duration_jitters),
331
+ right_open: _hash_from_keys_and_values(hash_keys, right_open))
332
+ else
333
+ binder.apply(effective_values.first,
334
+ effective_next_values.first,
335
+ control: control,
336
+ duration: _durations(every_groups, effective_duration).first,
337
+ quantized_duration: q_durations.first,
338
+ position_jitter: position_jitters.first,
339
+ duration_jitter: duration_jitters.first,
340
+ started_ago: nil,
341
+ right_open: right_open.first)
342
+ end
343
343
 
344
344
  #
345
345
  # Do the REAL thing
@@ -268,7 +268,7 @@ module Musa
268
268
 
269
269
  when Array
270
270
  { current_operation: :no_eval_play,
271
- current_parameter: S(*element) }
271
+ current_parameter: Musa::Series::Constructors.S(*element) }
272
272
  else
273
273
  case element[:kind]
274
274
  when :value
@@ -292,7 +292,7 @@ module Musa
292
292
 
293
293
  if _value.is_a?(Array)
294
294
  { current_operation: :no_eval_play,
295
- current_parameter: S(*_value) }
295
+ current_parameter: Musa::Series::Constructors.S(*_value) }
296
296
  else
297
297
  { current_operation: :block,
298
298
  current_parameter: _value,
@@ -1,9 +1,9 @@
1
1
  require_relative '../core-ext/inspect-nice'
2
2
 
3
- using Musa::Extension::InspectNice
4
-
5
3
  module Musa::Sequencer
6
4
  class BaseSequencer
5
+ using Musa::Extension::InspectNice
6
+
7
7
  private def _play_timed(timed_serie, control, &block)
8
8
 
9
9
  if first_value_sample = timed_serie.peek_next_value
@@ -18,8 +18,8 @@ module Musa::Sequencer
18
18
 
19
19
  __play_eval ||= PlayEval.create \
20
20
  mode,
21
- SmartProcBinder.new(block,
22
- on_rescue: proc { |e| _rescue_error(e) }),
21
+ Musa::Extension::SmartProcBinder::SmartProcBinder.new(block,
22
+ on_rescue: proc { |e| _rescue_error(e) }),
23
23
  decoder,
24
24
  neumalang_context
25
25
 
@@ -1,9 +1,9 @@
1
1
  require_relative '../core-ext/smart-proc-binder'
2
2
  require_relative '../core-ext/inspect-nice'
3
3
 
4
- using Musa::Extension::InspectNice
5
-
6
4
  module Musa::Sequencer
5
+ using Musa::Extension::InspectNice
6
+
7
7
  class BaseSequencer
8
8
  private def _tick(position_to_run)
9
9
  @before_tick.each { |block| block.call position_to_run }
@@ -2,7 +2,6 @@ module Musa
2
2
  module Sequencer
3
3
  class BaseSequencer
4
4
  module TickBasedTiming
5
-
6
5
  using Musa::Extension::InspectNice
7
6
 
8
7
  attr_reader :position, :ticks_per_bar, :tick_duration
@@ -49,9 +48,11 @@ module Musa
49
48
  position = ticks_position.round * @tick_duration
50
49
 
51
50
  if warn
52
- @logger.warn('BaseSequencer') { "_check_position: rounding "\
51
+ @logger.warn('BaseSequencer') do
52
+ '_check_position: rounding ' \
53
53
  "position #{original_position.inspect} (#{original_position.to_f.round(5)}) "\
54
- "to tick precision: #{position.inspect} (#{position.to_f.round(5)})" }
54
+ "to tick precision: #{position.inspect} (#{position.to_f.round(5)})"
55
+ end
55
56
  end
56
57
  end
57
58
 
@@ -97,19 +97,19 @@ module Musa
97
97
  end
98
98
 
99
99
  def on_debug_at(&block)
100
- @on_debug_at << SmartProcBinder.new(block)
100
+ @on_debug_at << Musa::Extension::SmartProcBinder::SmartProcBinder.new(block)
101
101
  end
102
102
 
103
103
  def on_error(&block)
104
- @on_error << SmartProcBinder.new(block)
104
+ @on_error << Musa::Extension::SmartProcBinder::SmartProcBinder.new(block)
105
105
  end
106
106
 
107
107
  def on_fast_forward(&block)
108
- @on_fast_forward << SmartProcBinder.new(block)
108
+ @on_fast_forward << Musa::Extension::SmartProcBinder::SmartProcBinder.new(block)
109
109
  end
110
110
 
111
111
  def before_tick(&block)
112
- @before_tick << SmartProcBinder.new(block)
112
+ @before_tick << Musa::Extension::SmartProcBinder::SmartProcBinder.new(block)
113
113
  end
114
114
 
115
115
  def on(event, &block)
@@ -132,7 +132,7 @@ module Musa
132
132
  bars_delay = Series::S(*bars_delay) if bars_delay.is_a?(Array)
133
133
  bars_delay = bars_delay.instance if bars_delay
134
134
 
135
- _serie_at bars_delay.eval { |delay| position + delay }, control, debug: debug, &block
135
+ _serie_at bars_delay.with { |delay| position + delay }, control, debug: debug, &block
136
136
  end
137
137
 
138
138
  @event_handlers.pop
@@ -1,5 +1,7 @@
1
1
  require_relative '../series'
2
2
 
3
+ # TODO: esto sería un refinement, no?
4
+
3
5
  class Array
4
6
  def to_serie(of_series: nil, recursive: nil)
5
7
  of_series ||= false
@@ -8,11 +10,11 @@ class Array
8
10
  raise ArgumentError, 'Cannot convert to serie of_series and recursive simultaneously' if recursive && of_series
9
11
 
10
12
  if recursive
11
- S(*(collect { |_| _.is_a?(Array) ? _.to_serie(recursive: true) : _ }))
13
+ Musa::Series::Constructors.S(*(collect { |_| _.is_a?(Array) ? _.to_serie(recursive: true) : _ }))
12
14
  elsif of_series
13
- S(*(collect { |_| S(*_) }))
15
+ Musa::Series::Constructors.S(*(collect { |_| Musa::Series::Constructors.S(*_) }))
14
16
  else
15
- S(*self)
17
+ Musa::Series::Constructors.S(*self)
16
18
  end
17
19
  end
18
20
 
@@ -1,8 +1,6 @@
1
1
  require_relative '../core-ext/deep-copy'
2
2
  require_relative '../generative/generative-grammar'
3
3
 
4
- using Musa::Extension::DeepCopy
5
-
6
4
  module Musa
7
5
  module Series
8
6
  module Constructors; extend self; end
@@ -338,6 +336,8 @@ module Musa
338
336
  include Prototyping
339
337
  include Operations
340
338
 
339
+ using Musa::Extension::DeepCopy
340
+
341
341
  def init
342
342
  @_have_peeked_next_value = false
343
343
  @_peeked_next_value = nil
@@ -206,11 +206,6 @@ module Musa
206
206
  @index -= offset
207
207
  end
208
208
 
209
- # private def _init
210
- # @source.prototype.singleton._register(self) if instance?
211
- # @index = @last_nil_index
212
- # end
213
- #
214
209
  private def _sources_resolved
215
210
  @source.singleton._register(self) if instance?
216
211
  @index = @last_nil_index
@@ -3,13 +3,12 @@ require_relative '../core-ext/smart-proc-binder'
3
3
 
4
4
  require_relative 'base-series'
5
5
 
6
- using Musa::Extension::Arrayfy
7
- using Musa::Extension::ExplodeRanges
8
-
9
6
  # TODO: añadir en for: steps: (nº de pasos en los que repartir el incremento)
10
7
 
11
8
  module Musa
12
9
  module Series::Constructors
10
+ using Musa::Extension::ExplodeRanges
11
+
13
12
  def UNDEFINED
14
13
  UndefinedSerie.new
15
14
  end
@@ -119,7 +118,8 @@ module Musa
119
118
  end
120
119
  end
121
120
 
122
- private_constant :UndefinedSerie
121
+ # UndefinedSerie is not private because is used in Composer
122
+ # private_constant :UndefinedSerie
123
123
 
124
124
  class NilSerie
125
125
  include Series::Serie.base
@@ -136,6 +136,8 @@ module Musa
136
136
  class FromArray
137
137
  include Series::Serie.base
138
138
 
139
+ using Musa::Extension::Arrayfy
140
+
139
141
  def initialize(values = nil, extends = nil)
140
142
  @values = values
141
143
  mark_as_prototype!
@@ -84,11 +84,11 @@ module Musa
84
84
  end
85
85
 
86
86
  def after(*series)
87
- Sequence.new [self, *series]
87
+ Musa::Series::Constructors.MERGE self, *series
88
88
  end
89
89
 
90
90
  def +(other)
91
- Sequence.new [self, other]
91
+ Musa::Series::Constructors.MERGE self, other
92
92
  end
93
93
 
94
94
  def cut(length)
@@ -4,8 +4,6 @@ require_relative '../core-ext/inspect-nice'
4
4
  require_relative 'base-series'
5
5
 
6
6
  # TODO remove debugging puts, intermediate hash comments on :info and InspectNice
7
- using Musa::Extension::InspectNice
8
-
9
7
  module Musa
10
8
  module Series::Operations
11
9
  def quantize(reference: nil, step: nil,
@@ -70,7 +68,7 @@ module Musa
70
68
  time = n[0].rationalize
71
69
  value = n[1].rationalize
72
70
  else
73
- raise RuntimeError, "Don't know how to process #{n}"
71
+ raise "Don't know how to process #{n}"
74
72
  end
75
73
 
76
74
  return time, value
@@ -115,9 +113,8 @@ module Musa
115
113
  end
116
114
 
117
115
  private def _next_value
116
+ i = 2
118
117
  if @stops
119
- i = 2
120
-
121
118
  loop do
122
119
  while @segments.size < i && process2; end
123
120
 
@@ -142,17 +139,16 @@ module Musa
142
139
  return { time: first[:time],
143
140
  @value_attribute => first[:value],
144
141
  duration: durations_to_sum.sum { |_| _[:duration] } }
145
- .extend(Musa::Datasets::AbsTimed)
146
- .extend(Musa::Datasets::AbsD)
142
+ .extend(Musa::Datasets::AbsTimed)
143
+ .extend(Musa::Datasets::AbsD)
147
144
  else
148
145
  i += 1
149
146
  end
150
147
  end
151
148
 
152
- return nil
149
+ nil
153
150
 
154
151
  else
155
- i = 2
156
152
  # puts "\n\n"
157
153
  loop do
158
154
  while @segments.size < i && process2; end
@@ -179,8 +175,8 @@ module Musa
179
175
  return { time: first[:time],
180
176
  @value_attribute => first[:value],
181
177
  duration: durations_to_sum.sum { |_| _[:duration] } }
182
- .extend(Musa::Datasets::AbsTimed)
183
- .extend(Musa::Datasets::AbsD)
178
+ .extend(Musa::Datasets::AbsTimed)
179
+ .extend(Musa::Datasets::AbsD)
184
180
  else
185
181
  i += 1
186
182
  end
@@ -211,7 +207,7 @@ module Musa
211
207
 
212
208
  # puts "process2: from_time #{from_time} from_value #{from_value} to_time #{to_time} to_value #{to_value} to_last #{to_point_is_last || 'nil'} sign #{sign}"
213
209
 
214
- if sign == 0
210
+ if sign.zero?
215
211
  if @segments.last && @segments.last[:time] == from_time
216
212
 
217
213
  @segments.last[:duration] = to_time - from_time
@@ -261,8 +257,8 @@ module Musa
261
257
 
262
258
  loop_from_value.step(loop_to_value, step_value_increment) do |value|
263
259
  if @segments.last &&
264
- @segments.last[:time] == intermediate_point_time &&
265
- @segments.last[:value] == value
260
+ @segments.last[:time] == intermediate_point_time &&
261
+ @segments.last[:value] == value
266
262
 
267
263
  @segments.last[:duration] = step_time_increment
268
264
  @segments.last[:info] += '; edited on b'
@@ -294,7 +290,7 @@ module Musa
294
290
 
295
291
  private def process(time, value, last_time_value)
296
292
  if time && value
297
- raise RuntimeError, 'time only can go forward' if @last_processed_time && time <= @last_processed_time
293
+ raise 'time only can go forward' if @last_processed_time && time <= @last_processed_time
298
294
 
299
295
  q_value = round_quantize(value)
300
296
 
@@ -399,23 +395,23 @@ module Musa
399
395
  if @first
400
396
  @first = false
401
397
 
402
- if time > first_time
403
- result = { time: first_time,
398
+ result = if time > first_time
399
+ { time: first_time,
404
400
  @value_attribute => round_to_nearest_quantize(first_value, value),
405
401
  duration: time - first_time }
406
- .extend(Musa::Datasets::AbsD)
407
- .extend(Musa::Datasets::AbsTimed)
408
- else
409
- result = _next_value
410
- end
402
+ .extend(Musa::Datasets::AbsD)
403
+ .extend(Musa::Datasets::AbsTimed)
404
+ else
405
+ _next_value
406
+ end
411
407
  else
412
408
  if @crossings[1]
413
409
  next_time = @crossings[1][:time]
414
410
  result = { time: time,
415
411
  @value_attribute => value,
416
412
  duration: next_time - time }
417
- .extend(Musa::Datasets::AbsD)
418
- .extend(Musa::Datasets::AbsTimed)
413
+ .extend(Musa::Datasets::AbsD)
414
+ .extend(Musa::Datasets::AbsTimed)
419
415
 
420
416
  @crossings.shift
421
417
 
@@ -424,8 +420,8 @@ module Musa
424
420
  result = { time: @crossings[0][:time],
425
421
  @value_attribute => @crossings[0][@value_attribute],
426
422
  duration: @last_time - @crossings[0][:time] }
427
- .extend(Musa::Datasets::AbsD)
428
- .extend(Musa::Datasets::AbsTimed)
423
+ .extend(Musa::Datasets::AbsD)
424
+ .extend(Musa::Datasets::AbsTimed)
429
425
 
430
426
  @last_time = nil
431
427
  end
@@ -436,8 +432,8 @@ module Musa
436
432
  result = { time: first_time,
437
433
  value: round_to_nearest_quantize(first_value),
438
434
  duration: @last_time - first_time }
439
- .extend(Musa::Datasets::AbsD)
440
- .extend(Musa::Datasets::AbsTimed)
435
+ .extend(Musa::Datasets::AbsD)
436
+ .extend(Musa::Datasets::AbsTimed)
441
437
 
442
438
  @first = false
443
439
  @last_time = false
@@ -453,8 +449,8 @@ module Musa
453
449
  if @last_time.nil? || c[:time] > @last_time
454
450
 
455
451
  if c[:stop] &&
456
- @crossings.dig(-1, :stop) &&
457
- @crossings.dig(-1, @value_attribute) == c[@value_attribute]
452
+ @crossings.dig(-1, :stop) &&
453
+ @crossings.dig(-1, @value_attribute) == c[@value_attribute]
458
454
 
459
455
  c[:stops] = (@crossings[-1][:stops] || 0) + 1
460
456
 
@@ -473,7 +469,7 @@ module Musa
473
469
  from_time, from_value = get_time_value(@source.next_value)
474
470
 
475
471
  if from_time && from_value
476
- raise RuntimeError, "time only can go forward" if @last_time && from_time <= @last_time
472
+ raise 'time only can go forward' if @last_time && from_time <= @last_time
477
473
 
478
474
  @last_time = from_time
479
475
 
@@ -500,36 +496,36 @@ module Musa
500
496
  delta_time = to_time - from_time
501
497
 
502
498
  crossings =
503
- from_step.step(last_step, sign).collect do |i|
504
- value = @crossing_reference + i * @step_size
499
+ from_step.step(last_step, sign).collect do |i|
500
+ value = @crossing_reference + i * @step_size
505
501
 
506
- { time: from_time + (delta_time / delta_value) * (value - from_value),
507
- @value_attribute => value + sign * @halfway_offset }
508
- end
502
+ { time: from_time + (delta_time / delta_value) * (value - from_value),
503
+ @value_attribute => value + sign * @halfway_offset }
504
+ end
509
505
 
510
506
  if @include_stops
511
507
  first_crossing_time = crossings.dig(0, :time)
512
508
  last_crossing_time = crossings.dig(-1, :time)
513
509
 
514
- if first_crossing_time.nil? || from_time < first_crossing_time
515
- stop_before = [ { time: from_time,
510
+ stop_before = if first_crossing_time.nil? || from_time < first_crossing_time
511
+ [ { time: from_time,
516
512
  @value_attribute =>
517
- round_to_nearest_quantize(from_value,
518
- crossings.dig(0, @value_attribute)),
513
+ round_to_nearest_quantize(from_value,
514
+ crossings.dig(0, @value_attribute)),
519
515
  stop: true } ]
520
- else
521
- stop_before = []
522
- end
516
+ else
517
+ []
518
+ end
523
519
 
524
- if last_crossing_time.nil? || to_time > last_crossing_time
525
- stop_after = [ { time: to_time,
520
+ stop_after = if last_crossing_time.nil? || to_time > last_crossing_time
521
+ [ { time: to_time,
526
522
  @value_attribute =>
527
- round_to_nearest_quantize(to_value,
528
- crossings.dig(-1, @value_attribute)),
523
+ round_to_nearest_quantize(to_value,
524
+ crossings.dig(-1, @value_attribute)),
529
525
  stop: true } ]
530
- else
531
- stop_after = []
532
- end
526
+ else
527
+ []
528
+ end
533
529
 
534
530
  stop_before + crossings + stop_after
535
531
  else