keycounter 0.0.2 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/keycounter.rb +23 -5
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e5a65fd28d2851ea93b0e685b57343f78f0f42dc
4
- data.tar.gz: de44d399f162a2baa3648b4bd6bd1268d95507bc
3
+ metadata.gz: b74d39ab044f817903f9037596d7f3874cba9045
4
+ data.tar.gz: 3c0aaae49c4899882893d5bb59d56bcf57b53e2e
5
5
  SHA512:
6
- metadata.gz: f183b8b766f040a67f3a9cd7cb250d35298d7743baa53f193a784b02796a80490c3446fa76379415e6b7b161895e6b7029c531ac57d48c373a3f93bdeaed5ed8
7
- data.tar.gz: 98186bb84a446f8e7aada0d9b941964e895d72a2f26b4f2e4e13a02b9850777cfca778644945e0caa3aa458919779e371c32de67ccb39b9c2ad5287c43859408
6
+ metadata.gz: e907e4ce2b836a9f22b589d5c0ff99b55487375c0479e8e6cd0375fa34a5bd5af0fc95540cb5a3759e61ec5e97914ec954ca76d7ed75f09263e875502e9b1136
7
+ data.tar.gz: 7e1c89a294b717cfaf96dc9c736e9b5b7035022328246a1c60df669ac97b992e851fea561cffa26b224705ed560fa370580f9780faa98ecd22019fd9991ffc8e
@@ -10,15 +10,33 @@
10
10
 
11
11
  class Keycounter
12
12
 
13
+ attr_writer :verbose
14
+
15
+ def initialize
16
+ @verbose = true
17
+ end
18
+
13
19
  # Create / Add to instance variable
14
20
  def keycount(key)
15
21
  key.gsub!(" ", "_") # no spaces or case
16
- if !instance_variable_get("@#{key}")
17
- instance_variable_set("@#{key}", 1)
18
- else
19
- instance_variable_set("@#{key}", instance_variable_get("@#{key}") + 1)
22
+ begin
23
+ if !instance_variable_get("@#{key}")
24
+ instance_variable_set("@#{key}", 1)
25
+ else
26
+ begin
27
+ instance_variable_set("@#{key}", instance_variable_get("@#{key}") + 1)
28
+ rescue => e
29
+ puts "Cannot set instance variable of this name..."
30
+ pp e
31
+ end
32
+ end
33
+ rescue
34
+ puts "Cannot get instance variable of this name..."
35
+ pp e
36
+ end
37
+ if @verbose == true
38
+ puts "Key: #{key} Value: "+instance_variable_get("@#{key}").to_s
20
39
  end
21
- puts "Key: #{key} Value: "+instance_variable_get("@#{key}").to_s
22
40
  end
23
41
 
24
42
  # Read a single key
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keycounter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Hood