Sha256: fdd6aa357d86895334c3073e03255a75075c6dff35dd3ccc2db78b6c10736168

Contents?: true

Size: 576 Bytes

Versions: 3

Compression:

Stored size: 576 Bytes

Contents

class Array
  def to_proc
    if self[0].is_a? Symbol
      method, *arguments = self
      -> receiver { receiver.send method, *arguments }
    elsif self[1].is_a? Symbol
      receiver, method, *arguments = self
      if arguments.empty?
        -> argument { receiver.send method, argument }
      else
        # if some arguments were passed as well,
        # what is more reasonable for collection element?
        # to become the first or the last argument?
      end
    else
      arguments = self
      -> receiver { receiver.to_proc[*arguments] }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
to_proc-0.0.8 lib/to_proc/core/Array.rb
to_proc-0.0.7 lib/to_proc/core/Array.rb
to_proc-0.0.6 lib/to_proc/core/Array.rb