class PiedPiper

Constants

VERSION

Attributes

object[R]

Public Class Methods

new(object) click to toggle source
# File lib/pied_piper.rb, line 7
def initialize(object)
  @object = object
end

Public Instance Methods

end() click to toggle source
# File lib/pied_piper.rb, line 11
def end
  EndOfPipe
end
|(function) click to toggle source
# File lib/pied_piper.rb, line 15
def |(function)
  return object if function == EndOfPipe

  piped_result = result(function)
  PiedPiper.new(piped_result)
end

Private Instance Methods

result(function) click to toggle source
# File lib/pied_piper.rb, line 24
def result(function)
  case function
  when Symbol
    @object.send(function)
  when Array
    method, *args, blk = function
    case method

    when Symbol
      case blk
      when Proc
        @object.send(method, *args, &blk)
      else
        @object.send(method, *args, blk)
      end
    when Method
      method.call(@object, *args)
    end
  when Proc
    function.call(@object, *args)
  when Method
    function.call(@object, *args)
  end
end