store_as_int 0.0.17 → 0.0.18

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a67c2e9e601f6680d940d77d866b8e9eb65b5b3485e5624bd4c2b75e9fa9552d
4
- data.tar.gz: '0886a8271a81dce1d91481e4dbba6a412d704d8f169b99cb9541d6b05ccdf288'
3
+ metadata.gz: 4d911577180d2102c143b2c5b04846830e8cec0a3c9e9687014ee0d0c628720e
4
+ data.tar.gz: dbe23a3fd66f334f4c826a6e3acadf56e25e0ed2c43e3cf4a174d56b85e3a6ef
5
5
  SHA512:
6
- metadata.gz: 99ec022266e5e03971d7f5d1652a886bf228242fcc016baad0a0f10f7c39bc12217d43f00024cf3f4f70cfd2d2d8c1a1a5de5dc1ff71513fe3058a2644cf4ac2
7
- data.tar.gz: c35c4dc5ec9ce02ad34b289065f024a4ed25052080c93eb9a4bfa73bb41345937be2dbf1f409e353514de658e80ddb9fa2fa988158cc5e0e17f73693ee24c8e8
6
+ metadata.gz: 98313ea582b7d00daeee8bf5e80c8b36b91e6cbb9acd3d31a9e8766f5d99fb4399740d010db6962ee0aa0a9269c4dc6a460cd4196e7893208be2653b52060a5d
7
+ data.tar.gz: c56730ef9aebb7088eba481f811cd17648989afb20df20ebabd4d92948425323821df87cb47b9101a7b91edd09289d12e8e90ccbcab7ca805dcc7e86ec90147b
@@ -278,9 +278,9 @@ module StoreAsInt
278
278
  end
279
279
  end
280
280
 
281
- def to_s(w_sym = false)
281
+ def to_s(w_sym = false, padding: 0)
282
282
  begin
283
- str_format.call(self, w_sym)
283
+ str_format.call(self, w_sym, padding)
284
284
  rescue
285
285
  puts $!.message
286
286
  puts $!.backtrace
@@ -294,12 +294,12 @@ module StoreAsInt
294
294
 
295
295
  private
296
296
  def str_format
297
- @str_format ||= self.class.str_format || ->(passed, w_sym) do
298
- return '' unless w_sym || passed.present?
297
+ @str_format ||= self.class.str_format || ->(passed, w_sym, padding) do
298
+ return '' unless w_sym || passed.present? || (padding.to_i > 0)
299
299
  str = "#{
300
300
  passed.negative_sign
301
301
  }#{
302
- w_sym ? passed.sym : ''
302
+ (w_sym ? passed.sym : '').to_s.ljust(padding.to_i, ' ')
303
303
  }#{
304
304
  passed.decimals ?
305
305
  sprintf("%0.0#{passed.decimals.to_i}f", passed.to_d.abs) :
@@ -26,8 +26,8 @@ module StoreAsInt
26
26
  # == Comparison Methods ===================================================
27
27
 
28
28
  # == Instance Methods =====================================================
29
- def exchange_rate_str
30
- to_s(true)
29
+ def exchange_rate_str(padding: 0)
30
+ to_s(true, padding: padding.to_i)
31
31
  end
32
32
 
33
33
  def to_exchange_rate
@@ -36,8 +36,8 @@ module StoreAsInt
36
36
  end
37
37
 
38
38
  module ActsAsExchangeRateInt
39
- def exchange_rate_str
40
- to_exchange_rate.to_s(true)
39
+ def exchange_rate_str(padding: 0)
40
+ to_exchange_rate.to_s(true, padding: padding.to_i)
41
41
  end
42
42
 
43
43
  def to_exchange_rate
@@ -25,8 +25,8 @@ module StoreAsInt
25
25
  # == Comparison Methods ===================================================
26
26
 
27
27
  # == Instance Methods =====================================================
28
- def dollar_str
29
- to_s(true)
28
+ def dollar_str(padding: 0)
29
+ to_s(true, padding: padding.to_i)
30
30
  end
31
31
 
32
32
  def to_cents
@@ -35,8 +35,8 @@ module StoreAsInt
35
35
  end
36
36
 
37
37
  module ActsAsMoneyInt
38
- def dollar_str
39
- to_cents.to_s(true)
38
+ def dollar_str(padding: 0)
39
+ to_cents.to_s(true, padding: padding.to_i)
40
40
  end
41
41
 
42
42
  def to_cents
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.17
4
+ version: 0.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sampson Crowley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-23 00:00:00.000000000 Z
11
+ date: 2020-01-06 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
@@ -39,7 +39,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  requirements: []
42
- rubygems_version: 3.0.2
42
+ rubygems_version: 3.0.6
43
43
  signing_key:
44
44
  specification_version: 4
45
45
  summary: Store values as integers for lossless calculations