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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89426131c7ab950c53778513d6096be4495f7d6a5846fd42db9b8f31a0d69266
|
4
|
+
data.tar.gz: cbd2f6f94b7b83be5609e4e755250b64390897fb042d148efb5081d410eef41e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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.
|
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:
|
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
|