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



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

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)


9
10
11
# File 'lib/transproc/composite.rb', line 9

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)


14
15
16
# File 'lib/transproc/composite.rb', line 14

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)


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

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

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

See Also:



37
38
39
# File 'lib/transproc/composite.rb', line 37

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

#to_astObject

See Also:



46
47
48
# File 'lib/transproc/composite.rb', line 46

def to_ast
  left.to_ast << right.to_ast
end