sonic-pi

https://github.com/sonic-pi-net/sonic-pi

C++

Code. Music. Live.

Parslet::Transform#call_on_match

Executes the block on the bindings obtained by Pattern#match, if such a match
can be made. Depending on the arity of the given block, it is called in 
one of two environments: the current one or a clean toplevel environment.

If you would like the current environment preserved, please use the 
arity 1 variant of the block. Alternatively, you can inject a context object
and call methods on it (think :ctx => self).

  # the local variable a is simulated
  t.call_on_match(:a => :b) { a } 
  # no change of environment here
  t.call_on_match(:a => :b) { |d| d[:a] }

Source | Google | Stack overflow

Edit

git clone [email protected]:sonic-pi-net/sonic-pi.git

cd sonic-pi

open app/server/ruby/vendor/parslet/lib/parslet/transform.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-Parslet--Transform-call_on_match-for-pr


# Commit to git

git add app/server/ruby/vendor/parslet/lib/parslet/transform.rbgit commit -m "better docs for Parslet::Transform#call_on_match"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-Parslet--Transform-call_on_match-for-pr

hub pull-request


# Celebrate!