Class: Pacer::Wrappers::UnwrappingPipeFunction

Inherits:
Object
  • Object
show all
Defined in:
lib/pacer/wrappers/wrapping_pipe_function.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block) ⇒ UnwrappingPipeFunction

Returns a new instance of UnwrappingPipeFunction.



54
55
56
# File 'lib/pacer/wrappers/wrapping_pipe_function.rb', line 54

def initialize(block)
  @block = block
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



52
53
54
# File 'lib/pacer/wrappers/wrapping_pipe_function.rb', line 52

def block
  @block
end

Instance Method Details

#arityObject



58
59
60
# File 'lib/pacer/wrappers/wrapping_pipe_function.rb', line 58

def arity
  block.arity
end

#call_with_args(element, *args) ⇒ Object



73
74
75
76
77
78
79
80
# File 'lib/pacer/wrappers/wrapping_pipe_function.rb', line 73

def call_with_args(element, *args)
  e = block.call element, *args
  if e.is_a? ElementWrapper
    e.element
  else
    e
  end
end

#compute(element) ⇒ Object Also known as: call



62
63
64
65
66
67
68
69
# File 'lib/pacer/wrappers/wrapping_pipe_function.rb', line 62

def compute(element)
  e = block.call element
  if e.is_a? ElementWrapper
    e.element
  else
    e
  end
end