Module: CleanMethodable
- Extended by:
- ActiveSupport::Concern
- Included in:
- String
- Defined in:
- lib/ndr_support/string/clean_methodable.rb
Overview
Adds the ‘clean’ method to String, which can be used to clean strings in various ways depending on the contents
Constant Summary collapse
- ROMAN_ONE_TO_FIVE_MAPPING =
{ 'I' => '1', 'II' => '2', 'III' => '3', 'IIII' => '4', 'IV' => '4', 'V' => '5' }.freeze
- CLEAN_METHODS =
{ nhsnumber: :clean_nhsnumber, postcode: :clean_postcode, get_postcode: :clean_postcode, lpi: :clean_lpi, gender: :clean_gender, sex: :clean_sex, sex_c: :clean_sex_c, name: :clean_name, ethniccategory: :clean_ethniccategory, code: :clean_code, code_icd: :clean_code_icd, icd: :clean_icd, code_opcs: :clean_code_opcs, hospitalnumber: :clean_hospitalnumber, xmlsafe: :clean_xmlsafe, make_xml_safe: :clean_xmlsafe, roman5: :clean_roman5, tnmcategory: :clean_tnmcategory, strip: :strip, upcase: :upcase, itself: :itself, log10: :clean_log10 }.freeze
Instance Method Summary collapse
Instance Method Details
#clean(what) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/ndr_support/string/clean_methodable.rb', line 25 def clean(what) cleaning_method = CLEAN_METHODS[what] return send(cleaning_method) if cleaning_method gsub(' ?', ' ') end |