0.0
No commit activity in last 3 years
No release in over 3 years
Use arguments keyword in block.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.10
~> 10.0
>= 0
 Project Readme

Build Status

UseArguments

Use arguments keyword in block.

Installation

Add this line to your application's Gemfile:

gem 'use_arguments'

And then execute:

$ bundle

Or install it yourself as:

$ gem install use_arguments

Usage

require "use_arguments"

=begin
	Implicitly defined parameters in block.
	_1, _2..._N : argument value.
	_args       : argument array.
	_self       : self Proc object.
	_yield      : block argument.
	_receiver   : receiver object.
=end

# UseArguments::{Use args class name}
using UseArguments::Array
# or
# using UseArguments.usable Array

p [1, 2, 3].map { _1 + _1 }
# => [2, 4, 6]

# Splatted array argument.
p [[1, 2], [3, 4]].use_args.map { _1 + _2 }
# => [3, 7]

p [1, 2, 3].map { _1 + _receiver.size }
# => [4, 5, 6]


using UseArguments::Hash
p ({homu: 13, mami: 14, mado: 13}).select { _2 < 14 }
# => {:homu=>13, :mado=>13}

# Splatted array argument.
p data.map { "#{_1}:#{_2}" }
# => ["homu:13", "mami:14", "mado:13"]

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/osyo-manga/use_arguments.

Release note

  • 0.2.0

  • Splatted array argument.

  • Add _receiver parameter.

  • Support lambda.

  • Bug fix.

  • 0.1.0

  • Release!!

Special Thanks