Sha256: 8a6215028e8fad3db0b3ca517090a89687e96b02d18a84da016e8a2fc9ca312e

Contents?: true

Size: 627 Bytes

Versions: 4

Compression:

Stored size: 627 Bytes

Contents

# frozen_string_literal: true

require_relative 'translation'

module Loaf
  # A mixin for formatting crumb name
  module CrumbFormatter
    # @param [String] name
    #   the name to format
    #
    # @api public
    def format_name(name, options = {})
      return name if name.nil? || name.empty?

      formatted = name.to_s.dup
      formatted = Loaf::Translation.find_title(formatted)
      formatted = formatted.capitalize if options[:capitalize]
      if options[:crumb_length]
        formatted = truncate(formatted, length: options[:crumb_length])
      end
      formatted
    end
  end # CrumbFormatter
end # Loaf

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
loaf-0.7.0 lib/loaf/crumb_formatter.rb
loaf-0.6.2 lib/loaf/crumb_formatter.rb
loaf-0.6.1 lib/loaf/crumb_formatter.rb
loaf-0.6.0 lib/loaf/crumb_formatter.rb