Sha256: cd3dc15d6499311af568c06c3a511f9fb7da557875d1e03e5f80b64499608cff

Contents?: true

Size: 726 Bytes

Versions: 3

Compression:

Stored size: 726 Bytes

Contents

module LetterAvatar
  module AvatarHelper
    def letter_avatar_for(name, size = 64)
      LetterAvatar.generate(name, size)
    end

    def letter_avatar_url_for(avatar_path)
      avatar_path.to_s.sub('public/', '/')
    end

    def letter_avatar_url(name, size = 64)
      letter_avatar_url_for(letter_avatar_for(name, size))
    end

    def letter_avatar_tag(name, size = 64, options = {})
      if defined?(ActionView::Helpers::AssetTagHelper)
        extend ActionView::Helpers::AssetTagHelper
        image_tag(letter_avatar_url(name, size), options.merge(alt: name))
      else
        "<img alt=\"#{name}\" class\"#{options.fetch(:class)}\" src=\"#{letter_avatar_url(name, size)}\" />"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
letter_avatar-0.3.4 lib/letter_avatar/avatar_helper.rb
letter_avatar-0.3.3 lib/letter_avatar/avatar_helper.rb
letter_avatar-0.3.2 lib/letter_avatar/avatar_helper.rb