Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/musa-dsl/series/array-to-serie.rb

Overview

TODO: esto serĂ­a un refinement, no?

Instance Method Summary collapse

Instance Method Details

#to_serie(of_series: nil, recursive: nil) ⇒ Object Also known as: s

Raises:

  • (ArgumentError)


6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/musa-dsl/series/array-to-serie.rb', line 6

def to_serie(of_series: nil, recursive: nil)
  of_series ||= false
  recursive ||= false

  raise ArgumentError, 'Cannot convert to serie of_series and recursive simultaneously' if recursive && of_series

  if recursive
    Musa::Series::Constructors.S(*(collect { |_| _.is_a?(Array) ? _.to_serie(recursive: true) : _ }))
  elsif of_series
    Musa::Series::Constructors.S(*(collect { |_| Musa::Series::Constructors.S(*_) }))
  else
    Musa::Series::Constructors.S(*self)
  end
end