Module: Prawn::SwissQRBill::Helpers::NumberHelper

Included in:
Sections::PaymentAmount, Sections::ReceiptAmount
Defined in:
lib/prawn/swiss_qr_bill/helpers/number_helper.rb

Overview

Helpers to format numbers

Instance Method Summary collapse

Instance Method Details

#format_with_delimiter(number) ⇒ Object



8
9
10
11
12
# File 'lib/prawn/swiss_qr_bill/helpers/number_helper.rb', line 8

def format_with_delimiter(number)
  left, right = format('%.2f', number).split('.')
  left.gsub!(/(\d)(?=(\d\d\d)+(?!\d))/) { |d| "#{d} " }
  [left, right].compact.join('.')
end