README.md in hightop-0.2.0 vs README.md in hightop-0.2.1

- old
+ new

@@ -1,23 +1,39 @@ # Hightop A nice shortcut for group count queries -[![Build Status](https://travis-ci.org/ankane/hightop.svg)](https://travis-ci.org/ankane/hightop) - ```ruby Visit.top(:browser) ``` instead of ```ruby Visit.group(:browser).where("browser IS NOT NULL").order("count_all DESC, browser").count ``` -Be sure to [sanitize user input](http://rails-sqli.org/) like you must with `group`. +Be sure to [sanitize user input](https://rails-sqli.org/) like you must with `group` +Also works with arrays and hashes + +```ruby +["up", "up", "down"].top(1) +``` + +[![Build Status](https://travis-ci.org/ankane/hightop.svg)](https://travis-ci.org/ankane/hightop) + +## Installation + +Add this line to your application’s Gemfile: + +```ruby +gem 'hightop' +``` + +## Options + Limit the results ```ruby Visit.top(:referring_domain, 10) ``` @@ -35,11 +51,11 @@ ``` And expressions ```ruby -Visit.top("LOWER(referring_domain)") +Visit.top(Arel.sql("LOWER(referring_domain)")) ``` And distinct ```ruby @@ -50,21 +66,39 @@ ```ruby Visit.top(:city, min: 10) ``` -## Installation +## Arrays and Hashes -Add this line to your application’s Gemfile: +Arrays ```ruby -gem 'hightop' +["up", "up", "down"].top ``` -And then execute: +Hashes -```sh -bundle +```ruby +{a: "up", b: "up", c: "down"}.top { |k, v| v } +``` + +Limit the results + +```ruby +["up", "up", "down"].top(1) +``` + +Include nil values + +```ruby +[nil, nil, "down"].top(nil: true) +``` + +Min count + +```ruby +["up", "up", "down"].top(min: 2) ``` ## History View the [changelog](https://github.com/ankane/hightop/blob/master/CHANGELOG.md)