Sha256: b2eaf50fba35e13df654681ab2ed1f91dc1dff092d453a9da2bef88781617a16

Contents?: true

Size: 660 Bytes

Versions: 3

Compression:

Stored size: 660 Bytes

Contents

class Symbol

  # Useful extension for &:symbol which makes it possible
  # to pass arguments for method in block
  #
  #   ['abc','','','def','ghi'].tap(&:delete.(''))
  #   #=> ['abc','def','ghi']
  #
  #   [1,2,3].map(&:to_s.(2))
  #   #=> ['1','10','11']
  #
  #   ['abc','cdef','xy','z','wwww'].select(&:size.() == 4)
  #   #=> ['cdef', 'wwww']
  #
  #   ['abc','aaA','AaA','z'].count(&:upcase.().succ == 'AAB')
  #   #=> 2
  #
  #   [%w{1 2 3 4 5},%w{6 7 8 9}].map(&:join.().length)
  #   #=> [5,4]
  #
  # CREDIT: Ilya Vorontsov, Nobuyoshi Nakada

  def call(*args, &block)
    proc do |recv|
      recv.__send__(self, *args, &block)
    end
  end

end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
facets-glimmer-3.2.0 lib/core/facets/symbol/call.rb
facets-3.1.0 lib/core/facets/symbol/call.rb
facets-3.0.0 lib/core/facets/symbol/call.rb