Module: LetterAvatar::AvatarHelper
- Defined in:
- lib/letter_avatar/avatar_helper.rb
Instance Method Summary collapse
- #letter_avatar_for(name, size = 64) ⇒ Object
- #letter_avatar_tag(name, size = 64, options = {}) ⇒ Object
- #letter_avatar_url(name, size = 64) ⇒ Object
- #letter_avatar_url_for(avatar_path) ⇒ Object
Instance Method Details
#letter_avatar_for(name, size = 64) ⇒ Object
5 6 7 |
# File 'lib/letter_avatar/avatar_helper.rb', line 5 def letter_avatar_for(name, size = 64) LetterAvatar.generate(name, size) end |
#letter_avatar_tag(name, size = 64, options = {}) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/letter_avatar/avatar_helper.rb', line 17 def letter_avatar_tag(name, size = 64, = {}) if defined?(ActionView::Helpers::AssetTagHelper) include ActionView::Helpers::AssetTagHelper image_tag(letter_avatar_url(name, size), .merge(alt: name)) else "<img alt=\"#{name}\" class\"#{options.fetch(:class)}\" src=\"#{letter_avatar_url(name, size)}\" />" end end |
#letter_avatar_url(name, size = 64) ⇒ Object
13 14 15 |
# File 'lib/letter_avatar/avatar_helper.rb', line 13 def letter_avatar_url(name, size = 64) letter_avatar_url_for(letter_avatar_for(name, size)) end |
#letter_avatar_url_for(avatar_path) ⇒ Object
9 10 11 |
# File 'lib/letter_avatar/avatar_helper.rb', line 9 def letter_avatar_url_for(avatar_path) avatar_path.to_s.sub('public/','/') end |