Class: Numeric
- Inherits:
-
Object
- Object
- Numeric
- Defined in:
- lib/eac_rails_utils/patches/numeric/number_helper.rb
Constant Summary collapse
- DEFAULT_PRECISION =
2
Class Method Summary collapse
-
.number_helper ⇒ Object
A object that extends [ActionView::Helpers::NumberHelper].
Instance Method Summary collapse
- #default_precision_options(options = {}) ⇒ Object
-
#number_helper ⇒ Object
A object that extends [ActionView::Helpers::NumberHelper].
- #to_currency(options = {}) ⇒ String
- #to_human(options = {}) ⇒ String
- #to_human_size(options = {}) ⇒ String
- #to_percentage(options = {}) ⇒ String
- #to_phone(options = {}) ⇒ String
- #with_delimiter(options = {}) ⇒ String
- #with_precision(options = {}) ⇒ String
Class Method Details
.number_helper ⇒ Object
Returns A object that extends [ActionView::Helpers::NumberHelper].
10 11 12 13 14 15 16 |
# File 'lib/eac_rails_utils/patches/numeric/number_helper.rb', line 10 def number_helper @number_helper ||= begin r = ::Object.new r.extend(::ActionView::Helpers::NumberHelper) r end end |
Instance Method Details
#default_precision_options(options = {}) ⇒ Object
19 20 21 22 23 |
# File 'lib/eac_rails_utils/patches/numeric/number_helper.rb', line 19 def ( = {}) r = .dup r[:precision] = DEFAULT_PRECISION r end |
#number_helper ⇒ Object
Returns A object that extends [ActionView::Helpers::NumberHelper].
26 |
# File 'lib/eac_rails_utils/patches/numeric/number_helper.rb', line 26 delegate :number_helper, to: :class |
#to_currency(options = {}) ⇒ String
29 30 31 |
# File 'lib/eac_rails_utils/patches/numeric/number_helper.rb', line 29 def to_currency( = {}) number_helper.number_to_currency(self, ()) end |
#to_human(options = {}) ⇒ String
34 35 36 |
# File 'lib/eac_rails_utils/patches/numeric/number_helper.rb', line 34 def to_human( = {}) number_helper.number_to_human(self, ()) end |
#to_human_size(options = {}) ⇒ String
39 40 41 |
# File 'lib/eac_rails_utils/patches/numeric/number_helper.rb', line 39 def to_human_size( = {}) number_helper.number_to_human_size(self, ()) end |
#to_percentage(options = {}) ⇒ String
44 45 46 |
# File 'lib/eac_rails_utils/patches/numeric/number_helper.rb', line 44 def to_percentage( = {}) number_helper.number_to_percentage(self, ()) end |
#to_phone(options = {}) ⇒ String
49 50 51 |
# File 'lib/eac_rails_utils/patches/numeric/number_helper.rb', line 49 def to_phone( = {}) number_helper.number_to_phone(self, ) end |
#with_delimiter(options = {}) ⇒ String
54 55 56 |
# File 'lib/eac_rails_utils/patches/numeric/number_helper.rb', line 54 def with_delimiter( = {}) number_helper.number_with_delimiter(self, ) end |
#with_precision(options = {}) ⇒ String
59 60 61 |
# File 'lib/eac_rails_utils/patches/numeric/number_helper.rb', line 59 def with_precision( = {}) number_helper.number_with_precision(self, ()) end |