Module: Ballast::Emoji::Character

Includes:
ActionView::Helpers::TagHelper, ActiveSupport::Concern
Defined in:
lib/ballast/emoji.rb

Overview

Extensions for a emoji character.

Instance Method Summary collapse

Instance Method Details

#image_tag(options = {}) ⇒ String Also known as: html

Returns a image tag for the current character.

Returns:

  • (String)

    The options for the tag generation.

See Also:

  • ActionView::Helpers::TagHelper#tag


97
98
99
100
101
102
103
104
105
106
# File 'lib/ballast/emoji.rb', line 97

def image_tag(options = {})
  options = options.reverse_merge({alt: markup, title: markup, rel: "tooltip"})
  classes = options[:class].ensure_string.tokenize(pattern: /[\s,]+/, no_duplicates: true)
  classes << "emoji" unless classes.include?("emoji")

  options[:src] = url
  options[:class] = classes.uniq.join(" ")

  tag(:img, options)
end

#markupString

Returns a markup for the current character.

Returns:

  • (String)

    The markup for a character.



82
83
84
# File 'lib/ballast/emoji.rb', line 82

def markup
  ":#{name}:"
end

#urlString Also known as: image

Returns a image URL for the current character.

Returns:

  • (String)

    The image URL for the current character.



89
90
91
# File 'lib/ballast/emoji.rb', line 89

def url
  ::Emoji.url_for(image_filename)
end