Class: Transproc::Function

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Function.



20
21
22
23
# File 'lib/transproc.rb', line 20

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

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



18
19
20
# File 'lib/transproc.rb', line 18

def args
  @args
end

#fnObject (readonly)

Returns the value of attribute fn.



18
19
20
# File 'lib/transproc.rb', line 18

def fn
  @fn
end

Instance Method Details

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



25
26
27
# File 'lib/transproc.rb', line 25

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

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



30
31
32
# File 'lib/transproc.rb', line 30

def compose(other)
  self.class.new(-> value { other[fn[value]] })
end