store_as_int 0.0.13 → 0.0.14
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.
- checksums.yaml +4 -4
- data/lib/store_as_int/base.rb +9 -7
- data/lib/store_as_int/exchange_rate.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67e0e708079f8b602ee41a17efaef8b7af9478d2235d888e1a0930c4529f040b
|
4
|
+
data.tar.gz: bd04fa9baab51ae37b21f4d88ff16e3f1ed37e12c214f3f6a1c661a731542109
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 119556737a075d197bef945399315e57a1ecbf6225cf5a2c5b461481f2575c83eff78a7575f9c44d9261590eee61a4844a2d50513f1e8396a5881c1ab57bb353
|
7
|
+
data.tar.gz: 39d3b83b189a5a76a7f2d003c39885f84630c629b64373af5c499f05f7d06024a9905da7511b9c59b7f45991af7ae9c9f2e0b06bfa300c0bb72af38ecf79308a
|
data/lib/store_as_int/base.rb
CHANGED
@@ -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
|
-
|
177
|
+
convert(value.__send__(name, convert(*args).value))
|
176
178
|
else
|
177
179
|
ret = value.send(name, *args, &blk)
|
178
|
-
ret.is_a?(Numeric) ?
|
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
|
-
|
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.
|
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-
|
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
|