{"name":"addy","downloads":14423,"version":"1.1.0","version_created_at":"2010-06-29T00:20:35.311Z","version_downloads":8008,"platform":"ruby","authors":"Allen Madsen","info":"# Addy\n\nAllows pretty summations. Instead of writing:\n\n    (1..5).inject(0) do |memo, num|\n      memo + (num**num)\n    end\n\nYou write:\n\n    sum(1..5) do |num|\n      num**num\n    end\n\nPersonally, I would rather write the latter.\n\n## Usage\n\nInstall the gem:\n\n    gem install addy\n\nThen use it!\n\n    require 'addy'\n\n    class MyClass\n      #include it in a class or in Object to get it everywhere\n      include Addy\n\n      def my_awesome_adder(range)\n        sum(range)\n      end\n    end\n\nWhen you include addy on a class that implements inject, you don't even need to pass a value to it. Instead it calls sum on your class.\n\n    require 'addy'\n\n    class MyClass < Range\n      include Addy\n\n      def my_awesome_adder\n        sum\n      end\n    end\n\n### Calling It\nYou can call either sum or summation. They're aliases for the same thing.\n\nNote: The following assumes Addy is included into Range.\n\nWhen you pass a block to sum it will execute the block on the current number before adding it to the sum.\n\n    sum(1..5) {|num| num + 1}  #=> 20\n    (1..5).sum {|num| num + 1} #=> 20\n\nYou don't have to pass a block though!\n\n    #this\n    sum(1..5)              #=> 15\n    #and\n    (1..5).sum             #=> 15\n\n    #are equivalent to\n    sum(1..5) {|num| num}  #=> 15\n    #and\n    (1..5).sum {|num| num} #=> 15\n\n### Input\nRanges and numeric arrays both work well.\n\n    sum(1..5)         #=> 15\n    sum([1,2,3,4,5])  #=> 15\n\n## Note on Patches/Pull Requests\n\n* Fork the project.\n* Make your feature addition or bug fix.\n* Add tests for it. This is important so I don't break it in a\n  future version unintentionally.\n* Commit, do not mess with rakefile, version, or history.\n  (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)\n* Send me a pull request. Bonus points for topic branches.\n\n## Copyright\n\nCopyright (c) 2010 Allen Madsen. See LICENSE for details.\n\nPS: Isn't it ridiculous how much documentation I wrote for one function?","licenses":null,"metadata":{"homepage_uri":"http://github.com/blatyo/addy"},"yanked":false,"sha":"c3a8441de42c9fd0b8ead488e35155f3d3454c2761319e9f19ed3c96ee4060e6","spec_sha":"4d6e1f1f87a24784502353d5639aa838ae0f99be71279b5e76f56ba6ab33d972","project_uri":"https://rubygems.org/gems/addy","gem_uri":"https://rubygems.org/gems/addy-1.1.0.gem","homepage_uri":"http://github.com/blatyo/addy","wiki_uri":null,"documentation_uri":null,"mailing_list_uri":null,"source_code_uri":null,"bug_tracker_uri":null,"changelog_uri":null,"funding_uri":null,"dependencies":{"development":[{"name":"cucumber","requirements":">= 0"},{"name":"rspec","requirements":">= 1.3.0"},{"name":"yard","requirements":">= 0"}],"runtime":[]}}