Module: LeccaClient::Utils

Instance Method Summary collapse

Instance Method Details

#justify_number(number, length) ⇒ Object



7
8
9
# File 'lib/lecca_client/utils.rb', line 7

def justify_number(number, length)
  number.to_s.rjust(length, '0')
end

#justify_string(string, length) ⇒ Object



3
4
5
# 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) ⇒ Object



11
12
13
# 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