Module: WireClient::Converter::InstanceMethods
- Defined in:
- lib/wire_client/base/converters.rb
Instance Method Summary collapse
Instance Method Details
#convert_decimal(value) ⇒ Object
39 40 41 42 43 |
# File 'lib/wire_client/base/converters.rb', line 39 def convert_decimal(value) return unless value.present? value = BigDecimal(value.to_f&.to_s) value.round(2) if value&.finite? && value.positive? end |
#convert_text(value) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/wire_client/base/converters.rb', line 19 def convert_text(value) return unless value.present? value.to_s. # Replace some special characters described as "Best practices" # in Chapter 6.2 of this document: # http://www.europeanpaymentscouncil.eu/index.cfm/knowledge-bank/epc-documents/sepa-requirements-for-an-extended-character-set-unicode-subset-best-practices/ tr('€', 'E'). gsub('@', '(at)'). tr('_', '-'). # Replace linebreaks by spaces gsub(/\n+/, ' '). # Remove all invalid characters gsub(/[^a-zA-Z0-9ÄÖÜäöüß&*$%\ \'\:\?\,\-\(\+\.\)\/]/, ''). # Remove leading and trailing spaces strip end |