Module: Ramda::Internal::FunctionWithArity

Defined in:
lib/ramda/internal/function_with_arity.rb

Overview

Curried Method

Class Method Summary collapse

Class Method Details

.call(arity) ⇒ Object

rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/MethodLength rubocop:disable Metrics/ParameterLists



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ramda/internal/function_with_arity.rb', line 8

def self.call(arity)
  case arity
  when 0, -1
    ->(*a) { yield(*a) }
  when 1, -2
    ->(a, *b) { yield(a, *b) }
  when 2, -3
    ->(a, b, *c) { yield(a, b, *c) }
  when 3, -4
    ->(a, b, c, *d) { yield(a, b, c, *d) }
  when 4, -5
    ->(a, b, c, d, *e) { yield(a, b, c, d, *e) }
  when 5, -6
    ->(a, b, c, d, e, *f) { yield(a, b, c, d, e, *f) }
  when 6, -7
    ->(a, b, c, d, e, f, *g) { yield(a, b, c, d, e, f, *g) }
  else
    raise ArgumentError, "Arrity #{arity} is not supported"
  end
end