module PBatcher::Printer

Constants

FAILURE_MESSAGE
OVERFLOW
SUCCESS_MESSAGE

Public Instance Methods

failure() click to toggle source
# File lib/pbatcher/printer.rb, line 18
def failure
  print "[#{FAILURE_MESSAGE}]"
end
message(str, options = { max_size: 90 }) click to toggle source
# File lib/pbatcher/printer.rb, line 10
def message(str, options = { max_size: 90 })
  print message_str(str, options)
end
newline() click to toggle source
# File lib/pbatcher/printer.rb, line 22
def newline
  puts ''
end
success() click to toggle source
# File lib/pbatcher/printer.rb, line 14
def success
  print "[#{SUCCESS_MESSAGE}]"
end

Private Instance Methods

message_str(str, options) click to toggle source
# File lib/pbatcher/printer.rb, line 28
def message_str(str, options)
  return message_str_overflow(str, options) if message_str_overflow?(str, options)
  message_str_normal(str, options)
end
message_str_normal(str, options) click to toggle source
# File lib/pbatcher/printer.rb, line 37
def message_str_normal(str, options)
  str.ljust options[:max_size]
end
message_str_overflow(str, options) click to toggle source
# File lib/pbatcher/printer.rb, line 33
def message_str_overflow(str, options)
  str[0...(options[:max_size] - OVERFLOW.size)] + OVERFLOW
end
message_str_overflow?(str, options) click to toggle source
# File lib/pbatcher/printer.rb, line 41
def message_str_overflow?(str, options)
  str.size > options[:max_size] - OVERFLOW.size
end