[ANN] Multiblocks 0.1.0 -- emulating Smalltalk type multiblock calls

C

Csaba Henk

Hi list, group,

I'm glad to announce:

Multiblocks
===========

A framework for defining callgroups, that is, a group of methods which
behave in a somewhat Smalltalkish way, ie. they appear to be one method
which can take multiple blocks.

Location
--------

The homepage is

http://www.creo.hu/~csaba/ruby/multiblocks/

There is also a Rubyforge project page:

http://rubyforge.org/projects/multiblocks/

Distributed as gem, zip, and tarball (a quick link to this):

http://www.creo.hu/~csaba/ruby/multiblocks/download/multiblocks-0.1.0.tar.gz

under the Ruby License.

Example
-------

In following example a callgroup will be created, where the calls in the
group take keys and blocks, and upon execution, the blocks are called in
order according to the keys.

class PermuteBlocks
callgroup:)do,:&)
def sanitizer
@grpargv[-1][1].size == 1 and @grpargv[-1][2]
end
grp_finalizer :end do
@grpargv.sort_by {|a| a[1]}.each {|a| a[2][] }
end
end

PermuteBlocks.new.do(2){puts "a"}.&(1){puts "b"}.&(3){puts "c"}.end
p PermuteBlocks.callgroups

produces:

b
a
c
{:mad:grpargv=>{:calls=>[:do, :&], :sanitizer=>:sanitizer, :finalizers=>[:end]}}

It can be also useful if one needs keyword arguments with reflection.
That is, instead of writing something like

Server.start:)port => 1234, :dir => "/tmp/foo", :user => "nobody")

one could write

Server.port(1234).dir("/tmp/foo").user("nobody").start

Further features
--------
* thread safe
* provides a clean and simple way for structuring arguments of
complex method calls

Documentation
-------------

Rdoc. Online version at

http://www.creo.hu/~csaba/ruby/multiblocks/rdoc


Csaba
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top