Class: Transproc::Function

Inherits:
Object
  • Object
show all
Defined in:
lib/transproc/function.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fn, args = []) ⇒ Function

Returns a new instance of Function.



5
6
7
8
# File 'lib/transproc/function.rb', line 5

def initialize(fn, args = [])
  @fn = fn
  @args = args
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



3
4
5
# File 'lib/transproc/function.rb', line 3

def args
  @args
end

#fnObject (readonly)

Returns the value of attribute fn.



3
4
5
# File 'lib/transproc/function.rb', line 3

def fn
  @fn
end

Instance Method Details

#call(value) ⇒ Object Also known as: []



10
11
12
# File 'lib/transproc/function.rb', line 10

def call(value)
  fn[value, *args]
end

#compose(other) ⇒ Object Also known as: +



15
16
17
# File 'lib/transproc/function.rb', line 15

def compose(other)
  self.class.new(-> *result { other[fn[*result]] }, args)
end