Class: Cmdlet::Str::Padr

Inherits:
BaseCmdlet show all
Defined in:
lib/cmdlet/str/padr.rb

Overview

Padr: take the value and give it padding on the right hand side

Instance Method Summary collapse

Methods inherited from BaseCmdlet

#tokenizer

Instance Method Details

#call(value, count = nil, char = nil) ⇒ String



13
14
15
16
17
18
19
# File 'lib/cmdlet/str/padr.rb', line 13

def call(value, count = nil, char = nil)
  value = '' if value.nil?
  count = KConfig.configuration.cmdlet.padr_count if count.nil?
  count = count.to_i if count.is_a?(String)
  char = KConfig.configuration.cmdlet.padr_char if char.nil?
  value.to_s.ljust(count, char)
end