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 27 28 |
# File 'lib/eac_rails_utils/patches/numeric/number_helper.rb', line 26 def number_helper self.class.number_helper end |
#to_currency(options = {}) ⇒ String
31 32 33 |
# File 'lib/eac_rails_utils/patches/numeric/number_helper.rb', line 31 def to_currency( = {}) number_helper.number_to_currency(self, ()) end |
#to_human(options = {}) ⇒ String
36 37 38 |
# File 'lib/eac_rails_utils/patches/numeric/number_helper.rb', line 36 def to_human( = {}) number_helper.number_to_human(self, ()) end |
#to_human_size(options = {}) ⇒ String
41 42 43 |
# File 'lib/eac_rails_utils/patches/numeric/number_helper.rb', line 41 def to_human_size( = {}) number_helper.number_to_human_size(self, ()) end |
#to_percentage(options = {}) ⇒ String
46 47 48 |
# File 'lib/eac_rails_utils/patches/numeric/number_helper.rb', line 46 def to_percentage( = {}) number_helper.number_to_percentage(self, ()) end |
#to_phone(options = {}) ⇒ String
51 52 53 |
# File 'lib/eac_rails_utils/patches/numeric/number_helper.rb', line 51 def to_phone( = {}) number_helper.number_to_phone(self, ) end |
#with_delimiter(options = {}) ⇒ String
56 57 58 |
# File 'lib/eac_rails_utils/patches/numeric/number_helper.rb', line 56 def with_delimiter( = {}) number_helper.number_with_delimiter(self, ) end |
#with_precision(options = {}) ⇒ String
61 62 63 |
# File 'lib/eac_rails_utils/patches/numeric/number_helper.rb', line 61 def with_precision( = {}) number_helper.number_with_precision(self, ().print_debug) end |