eac_rails_utils 0.14.1 → 0.15.0

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: 7137f7331f9f361c5371306a1c2c607495dd3897bef11c887aad02535814c312
4
- data.tar.gz: b226cce4f9f3dc400a97426fa13a0d00d5fa2d157fd48bbda07873218832bd45
3
+ metadata.gz: 89426131c7ab950c53778513d6096be4495f7d6a5846fd42db9b8f31a0d69266
4
+ data.tar.gz: cbd2f6f94b7b83be5609e4e755250b64390897fb042d148efb5081d410eef41e
5
5
  SHA512:
6
- metadata.gz: 51cab365aec88b22c1a4765e3537f8b661eff6e06290210b5cd79e4d18f2a07a8de3c7ee059eb5b0809e71359c9c855cbee406f0d94c7a8381de78f45dbdebeb
7
- data.tar.gz: b2e42d61fbf1ed64f5297a7762e0bde11522682c12d02e4d9ca864d3000def5d037d512134bbae2ad9e998f4a3567f5326fb81db29e3fe5a9870b1f1926266ce
6
+ metadata.gz: da342b910c131c7c020ae55d89347f897378424a1aa1c6e82ca66ef5c98ba275261307c06ad4fb6aca08c5d467fde6d629f56400cb2ce79ba72e21bc006d33d3
7
+ data.tar.gz: dc082d3c3eafdd8fb0d040d703b0e4692ef110621777caae15150d5c2b6398538bfb7237c166b157ae38cbe9f5717a9aa942d9d942e824a704b38330f91e6d80
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'action_view/helpers/number_helper'
4
+
5
+ class Numeric
6
+ DEFAULT_PRECISION = 2
7
+
8
+ class << self
9
+ # @return [Object] A object that extends [ActionView::Helpers::NumberHelper]
10
+ def number_helper
11
+ @number_helper ||= begin
12
+ r = ::Object.new
13
+ r.extend(::ActionView::Helpers::NumberHelper)
14
+ r
15
+ end
16
+ end
17
+ end
18
+
19
+ def default_precision_options(options = {})
20
+ r = options.dup
21
+ r[:precision] = DEFAULT_PRECISION
22
+ r
23
+ end
24
+
25
+ # @return [Object] A object that extends [ActionView::Helpers::NumberHelper]
26
+ def number_helper
27
+ self.class.number_helper
28
+ end
29
+
30
+ # @return [String]
31
+ def to_currency(options = {})
32
+ number_helper.number_to_currency(self, default_precision_options(options))
33
+ end
34
+
35
+ # @return [String]
36
+ def to_human(options = {})
37
+ number_helper.number_to_human(self, default_precision_options(options))
38
+ end
39
+
40
+ # @return [String]
41
+ def to_human_size(options = {})
42
+ number_helper.number_to_human_size(self, default_precision_options(options))
43
+ end
44
+
45
+ # @return [String]
46
+ def to_percentage(options = {})
47
+ number_helper.number_to_percentage(self, default_precision_options(options))
48
+ end
49
+
50
+ # @return [String]
51
+ def to_phone(options = {})
52
+ number_helper.number_to_phone(self, options)
53
+ end
54
+
55
+ # @return [String]
56
+ def with_delimiter(options = {})
57
+ number_helper.number_with_delimiter(self, options)
58
+ end
59
+
60
+ # @return [String]
61
+ def with_precision(options = {})
62
+ number_helper.number_with_precision(self, default_precision_options(options).print_debug)
63
+ end
64
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/require_sub'
4
+ ::EacRubyUtils.require_sub __FILE__
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRailsUtils
4
- VERSION = '0.14.1'
4
+ VERSION = '0.15.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_rails_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.1
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - E.A.C.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-23 00:00:00.000000000 Z
11
+ date: 2022-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel-associations
@@ -196,6 +196,8 @@ files:
196
196
  - lib/eac_rails_utils/patches.rb
197
197
  - lib/eac_rails_utils/patches/action_controller_base.rb
198
198
  - lib/eac_rails_utils/patches/active_model_associations.rb
199
+ - lib/eac_rails_utils/patches/numeric.rb
200
+ - lib/eac_rails_utils/patches/numeric/number_helper.rb
199
201
  - lib/eac_rails_utils/patches/rails_4.rb
200
202
  - lib/eac_rails_utils/patches/rails_4/active_record_associations_association_scope.rb
201
203
  - lib/eac_rails_utils/patches/rails_5_2.rb