Module: Measurb::CoreExt
- Defined in:
- lib/measurb/core_ext.rb
Overview
Module for extending core classes
Class Method Summary collapse
-
.add_numeric_dimension(name, dimension_class_name, abbrev) ⇒ nil
Add the dimension name method to ‘Numeric`.
Class Method Details
.add_numeric_dimension(name, dimension_class_name, abbrev) ⇒ nil
Add the dimension name method to ‘Numeric`
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/measurb/core_ext.rb', line 19 def self.add_numeric_dimension(name, dimension_class_name, abbrev) def_string = " def \#{name}(precision = \#{DEFAULT_PRECISION})\n Measurb::\#{dimension_class_name}.new(self, precision)\n end\n EOS\n\n unless abbrev.nil?\n def_string << \"\\nalias_method :\#{abbrev}, :\#{name}\"\n end\n\n Numeric.class_eval(def_string)\nend\n" |