Sha256: 2a58f35ba2a991817411de1f0be57f26d29935598c75808aca65a958a702a6d6

Contents?: true

Size: 433 Bytes

Versions: 1

Compression:

Stored size: 433 Bytes

Contents

# frozen_string_literal: true

module ElectionBuddy
  class ErrorFormatter
    def self.format(error_hash)
      return if error_hash.nil? || error_hash.empty?

      error_hash.map do |key, value|
        formatted_key = key.gsub("_", " ").split.map(&:capitalize).join(" ")
        formatted_value = value.is_a?(Array) ? value.join(", ") : value
        "#{formatted_key}: #{formatted_value}"
      end.join(", ")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
electionbuddy-ruby-0.2.0 lib/election_buddy/error_formatter.rb