def formatted_value(value, format, width)
      value_str = value ? format(format, value) : ' ' * width # all space for nil value
      length = value_str.length
      if length > width
        value_str.slice(0..width - 1)
      elsif length < width
        ' ' * (width - length) + value_str
      else
        value_str
      end
    end
def formatted_value(value, format, width)
      value_str = value ? format(format, value) : ' ' * width # all space for nil value
      length = value_str.length
      if length > width
        value_str.slice(0..width - 1)
      elsif length < width
        ' ' * (width - length) + value_str
      else
        value_str
      end
    end
format the string using given format
 if the result is shorter than width, pad space to the left
 if the result is longer than width, truncate the last characters