store_as_int 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac0aa2949e48139e5ab1607f3290b1084c9c7559ae24eb5700dea195bcc3b142
4
- data.tar.gz: 507fb4a73ba8ab74261177eb08a9b386d10598b58c8440579d2f96dfb45b26d1
3
+ metadata.gz: 67e0e708079f8b602ee41a17efaef8b7af9478d2235d888e1a0930c4529f040b
4
+ data.tar.gz: bd04fa9baab51ae37b21f4d88ff16e3f1ed37e12c214f3f6a1c661a731542109
5
5
  SHA512:
6
- metadata.gz: a247d53dcdfc04255edda57cda0630e9dae8e05806889d16156a53794213589548645c8ee92c645fc652a98d2e902901f84778892d7fa1bc14bdd9985aa20769
7
- data.tar.gz: d25ca8ca14dd38a94db102e187350d02f4da96712d19738c779e75b00b25c690ca2cf16f7a09b31363b05cbbf45a854a8a7cbf6afaf3a175b8ef97d9ac3e6506
6
+ metadata.gz: 119556737a075d197bef945399315e57a1ecbf6225cf5a2c5b461481f2575c83eff78a7575f9c44d9261590eee61a4844a2d50513f1e8396a5881c1ab57bb353
7
+ data.tar.gz: 39d3b83b189a5a76a7f2d003c39885f84630c629b64373af5c499f05f7d06024a9905da7511b9c59b7f45991af7ae9c9f2e0b06bfa300c0bb72af38ecf79308a
@@ -107,7 +107,9 @@ module StoreAsInt
107
107
  end
108
108
 
109
109
  # == Instance Methods =====================================================
110
- def initialize(new_val = nil)
110
+ def initialize(new_val = nil, new_sym = nil)
111
+ self.sym = new_sym if new_sym
112
+
111
113
  return self.num = nil unless new_val && (new_val != '')
112
114
 
113
115
  if new_val.is_a?(self.class)
@@ -151,7 +153,7 @@ module StoreAsInt
151
153
  end
152
154
 
153
155
  def convert(other_val)
154
- self.class.new(other_val)
156
+ self.class.new(other_val, sym)
155
157
  end
156
158
 
157
159
  def decimals
@@ -169,13 +171,13 @@ module StoreAsInt
169
171
  def matcher
170
172
  @matcher ||= self.class.matcher
171
173
  end
172
-
174
+
173
175
  def method_missing(name, *args, &blk)
174
176
  if self.operators[name.to_sym]
175
- self.class.new(value.__send__(name, convert(*args).value))
177
+ convert(value.__send__(name, convert(*args).value))
176
178
  else
177
179
  ret = value.send(name, *args, &blk)
178
- ret.is_a?(Numeric) ? self.class.new(ret) : ret
180
+ ret.is_a?(Numeric) ? convert(ret) : ret
179
181
  end
180
182
  end
181
183
 
@@ -192,8 +194,8 @@ module StoreAsInt
192
194
  @sym ||= self.class.sym || ''
193
195
  end
194
196
 
195
- def sym=(new_sym)
196
- @sym = new_sym
197
+ def sym=(new_sym = nil)
198
+ @sym = new_sym ? new_sym.to_s : self.class.sym
197
199
  end
198
200
 
199
201
  def to_d
@@ -20,6 +20,7 @@ module StoreAsInt
20
20
  def self.extend_numerics
21
21
  Numeric.include StoreAsInt::ActsAsExchangeRateInt
22
22
  end
23
+
23
24
  # == Boolean Methods ======================================================
24
25
 
25
26
  # == Comparison Methods ===================================================
@@ -36,7 +37,7 @@ module StoreAsInt
36
37
 
37
38
  module ActsAsExchangeRateInt
38
39
  def exchange_rate_str
39
- to_cents.to_s(true)
40
+ to_exchange_rate.to_s(true)
40
41
  end
41
42
 
42
43
  def to_exchange_rate
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: store_as_int
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sampson Crowley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-15 00:00:00.000000000 Z
11
+ date: 2018-06-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Seamlessly store different types of values (such as dollars) as integers
14
14
  email: sampsonsprojects@gmail.com