Class: Transproc::Composite Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Composition of two functions

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(left, right) ⇒ Composite

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Composite.



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

def initialize(left, right)
  @left = left
  @right = right
end

Instance Attribute Details

#leftProc (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Proc)


11
12
13
# File 'lib/transproc/composite.rb', line 11

def left
  @left
end

#rightProc (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Proc)


16
17
18
# File 'lib/transproc/composite.rb', line 16

def right
  @right
end

Instance Method Details

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

Call right side with the result from the left side

Parameters:

  • value (Object)

    The input value

Returns:

  • (Object)


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

def call(value)
  right.call(left.call(value))
end

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

See Also:



39
40
41
# File 'lib/transproc/composite.rb', line 39

def compose(other)
  self.class.new(self, other)
end

#to_astObject

See Also:



48
49
50
# File 'lib/transproc/composite.rb', line 48

def to_ast
  left.to_ast << right.to_ast
end