to_bar_graph 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bucketizer.rb +5 -1
  3. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 092d59cfa67889a5aa4600a6ff0d6233c42f2c82
4
- data.tar.gz: d67e8d5c77e6373df077e00023baabf6b3b04fcb
3
+ metadata.gz: 934d4994a754c78b54375842e37c10e378971948
4
+ data.tar.gz: 9da9dfe3a9dbdaf1b10059d21cfcae24f89ceb15
5
5
  SHA512:
6
- metadata.gz: e92c8d374e739d6d8bd7590b304c6d310e298980bb6a799833194840c0213db07b437fb5f6afbc5d8a6c048f4e82489f50034dde5f861cd8a2c85773d4738678
7
- data.tar.gz: 3fad59c01191bd9cecc094d4589ec60eacabadef2bbdecc96cde2e26de1e246725e68f908675e19c7b3168a1dfd80ba0a64325d1a8fe12e32510a7f181a27f22
6
+ metadata.gz: 3e3a895cc2b085be3fcae0079561e094acfa787a8f7157fb33746af5b97154916592e987c0bbb8447fe77368d9669855b9a8bc7c770881224fe4c32a6cd856b4
7
+ data.tar.gz: 9748492885997d62cb52443b01df734cb178b6648a27c5a15154db4c1d83bb33e2d59287a1083d6fbbb22b25f9e51e014a5656acd2ee56fbed8ece1534f9f4bf
data/lib/bucketizer.rb CHANGED
@@ -18,6 +18,8 @@ module ToBarGraph
18
18
  def create_buckets_from_array
19
19
  buckets = {}
20
20
 
21
+ @data.delete(nil)
22
+
21
23
  @data.each do |e|
22
24
  buckets[e] ||= 0
23
25
  buckets[e] += 1
@@ -29,11 +31,13 @@ module ToBarGraph
29
31
  def create_buckets_from_hash
30
32
  buckets = {}
31
33
 
32
- @data.each { |k, v| buckets[k] = v }
34
+ @data.each { |k, v| buckets[k] = v unless (v.nil? || k.nil?) }
33
35
 
34
36
  if(buckets.any? { |k, v| v.is_a?(String) })
35
37
  return buckets.map { |k, v| [k, v.to_i] }.to_h
36
38
  end
39
+
40
+
37
41
 
38
42
  return buckets
39
43
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: to_bar_graph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Sykes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-15 00:00:00.000000000 Z
11
+ date: 2015-12-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: 'Adds #to_bar_graph to Array and to Hash and prints a simple bar graph
14
- to stdout.'
13
+ description: 'Adds #to_bar_graph to Array and to Hash, returns a bar graph object,
14
+ and optionally prints a simple bar graph to stdout.'
15
15
  email: brettcsykes@gmail.com
16
16
  executables: []
17
17
  extensions: []