class Popro::Formatter::Sprintf

Public Class Methods

new(format_string = nil) click to toggle source
# File lib/popro/formatter.rb, line 118
def initialize(format_string = nil)
  @format_string = format_string
end

Public Instance Methods

call(info, *_args) click to toggle source
# File lib/popro/formatter.rb, line 122
def call(info, *_args)
  string_params = Hash.new { |_, k| info.public_send(k) }
  format_string.gsub('{n}', info.total_length.to_s) % string_params
end
format_string() click to toggle source
# File lib/popro/formatter.rb, line 127
def format_string
  @format_string ||= '[%<current>{n}s/%<total>-{n}s] %<pct_formatted>4s%%'
end