<commit_before>= Named Proc

== Setup

    gem install multi_block


== Named Procs

A named proc acts like a normal proc, but has got a name attribute. You can create it by calling a method with the desired name on +proc+:

    >> a = proc.even?{ |e| e.even? }
    => #<NamedProc:0x00000001ffc340@(irb):1>
    >> a.name
    => :even?
    >> a[42]
    => false

In the same way, you can create lambdas:

    >> b = lambda.doubler{ |e| e * 2 }
    => #<NamedProc:0x000000020685e0@(irb):7 (lambda)>
    >> b.name
    => :doubler
    >> b[21]
    => 42
    >> b.lambda?
    => true

== J-_-L

These gem was build during a codebrawl contest. See the original gist: https://gist.github.com/4b2f5fd0b45118e46d0f. You might also take a look at the other entries: http://codebrawl.com/contests/methods-taking-multiple-blocks

Released under the MIT License.
<commit_msg>add description to readme<commit_after>= Named Proc {<img src="https://travis-ci.org/janlelis/named_proc.png" />}[https://travis-ci.org/janlelis/named_proc]

When working with a lot of procs, naming them might become handy. It makes identifying them later easier, which can be utilized by your code. For example, it enables improves the usefulness of {multi_block}[https:/github.com/janlelis/multi_block], a gem that allows you to pass multiple procs to methods.


== Setup

Add to Gemfile:

    gem 'named_proc'


== Named Procs

A named proc acts like a normal proc, but it has a name attribute. You create it by calling a method with the desired name on +proc+:

    >> a = proc.even?{ |e| e.even? }
    => #<NamedProc:0x00000001ffc340@(irb):1>
    >> a.name
    => :even?
    >> a[42]
    => false

In the same way, you can create lambdas:

    >> b = lambda.doubler{ |e| e * 2 }
    => #<NamedProc:0x000000020685e0@(irb):7 (lambda)>
    >> b.name
    => :doubler
    >> b[21]
    => 42
    >> b.lambda?
    => true

== J-_-L

These gem was build during a codebrawl contest. See the original gist: https://gist.github.com/4b2f5fd0b45118e46d0f. You might also take a look at the other entries: http://codebrawl.com/contests/methods-taking-multiple-blocks

Released under the MIT License.

{'fraction_non_alphanumeric': 0.12447747329307943, 'fraction_numerical': 0.04366000928936368, 'mean_word_length': 3.2485207100591715, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 50, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2788316', 'n_tokens_mistral': 820, 'n_tokens_neox': 737, 'n_words': 246}