one-pivot 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/README.md +12 -5
  2. metadata +1 -1
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  ##Overview
4
4
  The **one-pivot** GEM provides a simple way to mine data from a list of objects. There are no constraints on the types of objects that you can pivot. You can pivot anything from a list of numbers to a list of ActiveRecord objects to anything in between.
5
5
 
6
- **`One::Pivot`** exposes two methods of importance.
6
+ **`One::Pivoter`** exposes two methods of importance.
7
7
 
8
8
  * **`pivot`** - runs a single pivot
9
9
  * **`multi-pivot`** - stacks multiple pivots into a single result
@@ -14,13 +14,20 @@ Lets have a look at some examples.
14
14
 
15
15
  _Note: there are a few advanced features not demonstrated in the examples below. For example, adding identifiers to pivots or attaching observers to pivot operations. We use these features at 1on1 to cache pivot results for each item. This gives us a big performance boost when the same item participates in multiple pivots during its lifetime... especially when the pivot Proc is an expensive operation. Have a look at the [tests](https://github.com/one-on-one/pivot/tree/master/test) when you want to dig a little deeper._
16
16
 
17
+ ##Installation
18
+ <pre>
19
+ <code>
20
+ gem install one-pivot
21
+ </code>
22
+ </pre>
23
+
17
24
  ##A simple single pivot
18
25
  <pre>
19
26
  <code>
20
27
  require 'one-pivot'
21
28
 
22
29
  # create the pivot instance
23
- pivoter = One::Pivot.new
30
+ pivoter = One::Pivoter.new
24
31
 
25
32
  # create a list of objects to pivot
26
33
  list = [1,2,3,4,5,6,7,8,9]
@@ -28,7 +35,7 @@ list = [1,2,3,4,5,6,7,8,9]
28
35
  # run a single pivot
29
36
  # note: the block passed to the pivot method is invoked for each item in the list
30
37
  # note: the result from the block will act as the 'key' in the resulting Hash
31
- result = pivoter.pivot {|item| item <= 5}
38
+ result = pivoter.pivot(list) {|item| item <= 5}
32
39
 
33
40
  # 'result' will be a Hash with the following structure
34
41
  {
@@ -46,7 +53,7 @@ require 'one-pivot'
46
53
 
47
54
  # create the pivot instance
48
55
  # note: the multi-pivot delimiter that was specified
49
- pivoter = One::Pivot.new
56
+ pivoter = One::Pivoter.new
50
57
 
51
58
  # create a list of objects to pivot
52
59
  list = [1,2,3,4,5,6,7,8,9]
@@ -117,7 +124,7 @@ result = pivoter.multi_pivot(list, *pivots)
117
124
 
118
125
  require 'one-pivot'
119
126
 
120
- pivoter = One::Pivot.new
127
+ pivoter = One::Pivoter.new
121
128
  # note that the pivot block returns an array
122
129
  # each unique value in the arrays returned will become a key in the resulting Hash
123
130
  result = pivoter.pivot(User.all) do |user|
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: one-pivot
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.9.2
5
+ version: 0.9.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Nathan Hopkins