module LeccaClient::Utils

Public Instance Methods

justify_number(number, length) click to toggle source
# File lib/lecca_client/utils.rb, line 7
def justify_number(number, length)
  number.to_s.rjust(length, '0')
end
justify_string(string, length) click to toggle source
# File lib/lecca_client/utils.rb, line 3
def justify_string(string, length)
  I18n.transliterate(string.to_s).truncate(length, omission: '').ljust(length, ' ')
end
justify_value(value, length, decimal_places = 2) click to toggle source
# File lib/lecca_client/utils.rb, line 11
def justify_value(value, length, decimal_places = 2)
  ("%.#{decimal_places}f" % (value || 0)).gsub(/[.,]/, '').rjust(length, '0')
end