Module: Musa::Series::Operations

Defined in:
lib/musa-dsl/series/base-series.rb,
lib/musa-dsl/series/proxy-serie.rb,
lib/musa-dsl/series/queue-serie.rb,
lib/musa-dsl/series/timed-serie.rb,
lib/musa-dsl/series/buffer-serie.rb,
lib/musa-dsl/series/quantizer-serie.rb,
lib/musa-dsl/series/series-composer.rb,
lib/musa-dsl/series/main-serie-operations.rb,
lib/musa-dsl/series/hash-or-array-serie-splitter.rb

Defined Under Namespace

Classes: ComposerAsOperationSerie, Processor

Instance Method Summary collapse

Instance Method Details

#+(other) ⇒ Object



90
91
92
# File 'lib/musa-dsl/series/main-serie-operations.rb', line 90

def +(other)
  Musa::Series::Constructors.MERGE self, other
end

#after(*series) ⇒ Object



86
87
88
# File 'lib/musa-dsl/series/main-serie-operations.rb', line 86

def after(*series)
  Musa::Series::Constructors.MERGE self, *series
end

#anticipate(&block) ⇒ Object



128
129
130
# File 'lib/musa-dsl/series/main-serie-operations.rb', line 128

def anticipate(&block)
  Anticipate.new self, &block
end

#autorestartObject



4
5
6
# File 'lib/musa-dsl/series/main-serie-operations.rb', line 4

def autorestart
  Autorestart.new self
end

#buffered(sync: false) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/musa-dsl/series/buffer-serie.rb', line 3

def buffered(sync: false)
  if sync
    SyncBufferSerie.new(self)
  else
    BufferSerie.new(self)
  end
end

#compact_timedObject



232
233
234
# File 'lib/musa-dsl/series/timed-serie.rb', line 232

def compact_timed
  TimedCompacter.new(self)
end

#composer(&block) ⇒ Object



9
10
11
# File 'lib/musa-dsl/series/series-composer.rb', line 9

def composer(&block)
  ComposerAsOperationSerie.new(self, &block)
end

#cut(length) ⇒ Object



94
95
96
# File 'lib/musa-dsl/series/main-serie-operations.rb', line 94

def cut(length)
  Cutter.new self, length
end

#flattenObject



26
27
28
# File 'lib/musa-dsl/series/main-serie-operations.rb', line 26

def flatten
  Flattener.new self
end

#flatten_timedObject



228
229
230
# File 'lib/musa-dsl/series/timed-serie.rb', line 228

def flatten_timed
  TimedFlattener.new(self)
end

#hashify(*keys) ⇒ Object

TODO: test case



35
36
37
# File 'lib/musa-dsl/series/main-serie-operations.rb', line 35

def hashify(*keys)
  HashFromSeriesArray.new self, keys
end

#lazy(&block) ⇒ Object



132
133
134
# File 'lib/musa-dsl/series/main-serie-operations.rb', line 132

def lazy(&block)
  LazySerieEval.new self, &block
end

#lockObject

TODO: test case



45
46
47
# File 'lib/musa-dsl/series/main-serie-operations.rb', line 45

def lock
  Locker.new self
end

#map(isolate_values: nil, &block) ⇒ Object



122
123
124
125
126
# File 'lib/musa-dsl/series/main-serie-operations.rb', line 122

def map(isolate_values: nil, &block)
  isolate_values ||= isolate_values.nil? ? false : isolate_values

  ProcessWith.new self, isolate_values: isolate_values, &block
end

#max_size(length) ⇒ Object



18
19
20
# File 'lib/musa-dsl/series/main-serie-operations.rb', line 18

def max_size(length)
  LengthLimiter.new self, length
end

#mergeObject



98
99
100
# File 'lib/musa-dsl/series/main-serie-operations.rb', line 98

def merge
  MergeSerieOfSeries.new self
end

#multiplex(*indexed_series, **hash_series) ⇒ Object



77
78
79
# File 'lib/musa-dsl/series/main-serie-operations.rb', line 77

def multiplex(*indexed_series, **hash_series)
  MultiplexSelector.new self, indexed_series, hash_series
end

#process_with(**parameters, &processor) ⇒ Object



30
31
32
# File 'lib/musa-dsl/series/main-serie-operations.rb', line 30

def process_with(**parameters, &processor)
  Processor.new self, parameters, &processor
end

#proxyObject

TODO add test case



45
46
47
# File 'lib/musa-dsl/series/proxy-serie.rb', line 45

def proxy
  Series::ProxySerie.new(self)
end

#quantize(reference: nil, step: nil, value_attribute: nil, stops: nil, predictive: nil, left_open: nil, right_open: nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/musa-dsl/series/quantizer-serie.rb', line 9

def quantize(reference: nil, step: nil,
             value_attribute: nil,
             stops: nil,
             predictive: nil,
             left_open: nil,
             right_open: nil)

  Series::Constructors.QUANTIZE(self,
                  reference: reference,
                  step: step,
                  value_attribute: value_attribute,
                  stops: stops,
                  predictive: predictive,
                  left_open: left_open,
                  right_open: right_open)
end

#queuedObject



86
87
88
# File 'lib/musa-dsl/series/queue-serie.rb', line 86

def queued
  Series::Constructors.QUEUE(self)
end

#randomize(random: nil) ⇒ Object

TODO: test case



55
56
57
58
# File 'lib/musa-dsl/series/main-serie-operations.rb', line 55

def randomize(random: nil)
  random ||= Random.new
  Randomizer.new self, random
end

#remove(block = nil, &yield_block) ⇒ Object



60
61
62
63
64
# File 'lib/musa-dsl/series/main-serie-operations.rb', line 60

def remove(block = nil, &yield_block)
  # TODO make history an optional block parameter (via keyparametersprocedurebinder)
  block ||= yield_block
  Remover.new self, &block
end

#repeat(times = nil, condition: nil, &condition_block) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/musa-dsl/series/main-serie-operations.rb', line 8

def repeat(times = nil, condition: nil, &condition_block)
  condition ||= condition_block

  if times || condition
    Repeater.new self, times, &condition
  else
    InfiniteRepeater.new self
  end
end

#reverseObject

TODO: test case



50
51
52
# File 'lib/musa-dsl/series/main-serie-operations.rb', line 50

def reverse
  Reverser.new self
end

#select(block = nil, &yield_block) ⇒ Object



66
67
68
69
70
# File 'lib/musa-dsl/series/main-serie-operations.rb', line 66

def select(block = nil, &yield_block)
  # TODO add optional history (via keyparametersprocedurebinder)
  block ||= yield_block
  Selector.new self, &block
end

#shift(shift) ⇒ Object

TODO: test case



40
41
42
# File 'lib/musa-dsl/series/main-serie-operations.rb', line 40

def shift(shift)
  Shifter.new self, shift
end

#skip(length) ⇒ Object



22
23
24
# File 'lib/musa-dsl/series/main-serie-operations.rb', line 22

def skip(length)
  Skipper.new self, length
end

#splitObject



3
4
5
# File 'lib/musa-dsl/series/hash-or-array-serie-splitter.rb', line 3

def split
  Splitter.new(self)
end

#switch(*indexed_series, **hash_series) ⇒ Object

TODO: test case



73
74
75
# File 'lib/musa-dsl/series/main-serie-operations.rb', line 73

def switch(*indexed_series, **hash_series)
  Switcher.new self, indexed_series, hash_series
end

#switch_serie(*indexed_series, **hash_series) ⇒ Object

TODO: test case



82
83
84
# File 'lib/musa-dsl/series/main-serie-operations.rb', line 82

def switch_serie(*indexed_series, **hash_series)
  SwitchFullSerie.new self, indexed_series, hash_series
end

#union_timed(*other_timed_series, key: nil, **other_key_timed_series) ⇒ Object



236
237
238
239
240
241
242
243
244
245
246
# File 'lib/musa-dsl/series/timed-serie.rb', line 236

def union_timed(*other_timed_series, key: nil, **other_key_timed_series)
  if key && other_key_timed_series.any?
    Series::Constructors.TIMED_UNION(key => self, **other_key_timed_series)

  elsif other_timed_series.any? && other_key_timed_series.empty?
    Series::Constructors.TIMED_UNION(self, *other_timed_series)

  else
    raise ArgumentError, 'Can\'t union an array of series with a hash of series'
  end
end

#with(*with_series, on_restart: nil, isolate_values: nil, **with_key_series, &block) ⇒ Object Also known as: eval

TODO on with and map methods implement parameter passing with cloning on restart as on E()



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/musa-dsl/series/main-serie-operations.rb', line 104

def with(*with_series, on_restart: nil, isolate_values: nil, **with_key_series, &block)
  if with_series.any? && with_key_series.any?
    raise ArgumentError, 'Can\'t use extra parameters series and key named parameters series'
  end

  extra_series = if with_series.any?
                   with_series
                 elsif with_key_series.any?
                   with_key_series
                 end

  isolate_values ||= isolate_values.nil? ? true : isolate_values

  ProcessWith.new self, extra_series, on_restart, isolate_values: isolate_values, &block
end