Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

gem for eliminating local variables from your ruby code

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .document
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Gemfile
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 VERSION
README.rdoc

localone

Local One adds Object#with and Kernel.let to help you use fewer local variables.

Wha?

%w{ doug bob }.with do |a|
  assert_equal "doug and bob", a.join(' and ')
end

assert_equal 'abcdef', let(:a=>'abc', :b=>'def'){ [a, b].join }

Why is that better than assigning the variables?

Discourages redefining variables leading to a more functional style, looks kind of cool.

What does Local One mean?

Local because it deals with local variables (like you would deal with a rat problem).

Local One because www.flickr.com/photos/phirleh/3873243860/

Does it work on my version of Ruby?

It has been tested on 1.8.6, 1.8.7, and 1.9.1 successfully. I'm having jruby + rvm problems right now, so not sure there. Can't get jeweler or bundler installed on macruby + jvm. Verdict: probably :)

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don't break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Copyright

Copyright © 2010 Bryce Kerley. See LICENSE for details.

Something went wrong with that request. Please try again.