[{"authors":"Allen Madsen","built_at":"2010-06-28T04:00:00.000Z","created_at":"2010-06-29T00:20:35.311Z","description":"# 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?","downloads_count":8017,"metadata":{"homepage_uri":"http://github.com/blatyo/addy"},"number":"1.1.0","summary":"Prettier summations in your code.","platform":"ruby","rubygems_version":">= 0","ruby_version":null,"prerelease":false,"licenses":null,"requirements":null,"sha":"c3a8441de42c9fd0b8ead488e35155f3d3454c2761319e9f19ed3c96ee4060e6","spec_sha":"4d6e1f1f87a24784502353d5639aa838ae0f99be71279b5e76f56ba6ab33d972"},{"authors":"Allen Madsen","built_at":"2010-06-19T04:00:00.000Z","created_at":"2010-06-19T20:30:16.832Z","description":"Prettier summations in your code.","downloads_count":6417,"metadata":{"homepage_uri":"http://github.com/blatyo/addy"},"number":"1.0.0","summary":"Prettier summations in your code.","platform":"ruby","rubygems_version":">= 0","ruby_version":null,"prerelease":false,"licenses":null,"requirements":null,"sha":"5f04ec572d220988c7b7f358c81c4e292eabc330d6ad499f14f0b9399269f95c","spec_sha":"98304f9fbf20f045f6056f6887f8c1df9fe145b05fda7d89705d4d21cb4944c3"}]