module Ballast::Emoji::Character

Extensions for a emoji character.

Public Instance Methods

html(options = {})
Alias for: image_tag
image()
Alias for: url
image_tag(options = {}) click to toggle source

Returns a image tag for the current character. @see ActionView::Helpers::TagHelper#tag

@return [String] The options for the tag generation.

# 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
Also aliased as: html
markup() click to toggle source

Returns a markup for the current character.

@return [String] The markup for a character.

# File lib/ballast/emoji.rb, line 82
def markup
  ":#{name}:"
end
url() click to toggle source

Returns a image URL for the current character.

@return [String] The image URL for the current character.

# File lib/ballast/emoji.rb, line 89
def url
  ::Emoji.url_for(image_filename)
end
Also aliased as: image