Sha256: 71c2939f23f67a36b509cccd09e1576dd272ab5d93c1788f580e8a8e4417d270

Contents?: true

Size: 1.64 KB

Versions: 1

Compression:

Stored size: 1.64 KB

Contents

# frozen_string_literal: true

# Tanuki Emoji
module TanukiEmoji
  autoload :VERSION, './lib/tanuki_emoji/version'
  autoload :Error, './lib/tanuki_emoji/errors'
  autoload :AlphaCodeAlreadyIndexedError, './lib/tanuki_emoji/errors'
  autoload :CodepointAlreadyIndexedError, './lib/tanuki_emoji/errors'
  autoload :Index, './lib/tanuki_emoji/index'
  autoload :Character, './lib/tanuki_emoji/character'
  autoload :Db, './lib/tanuki_emoji/db'

  # This denotes a "color" or "emoji" version
  EMOJI_VARIATION_SELECTOR = 0xFE0F
  # This denotes a "plain" (black/white) or "textual" version
  PLAIN_VARIATION_SELECTOR = 0xFE0E
  BASE_FLAG_TAG = 0x1F3F4
  # Zero Width Joiner is used in sequences to indicate they should all be evaluated and displayed as a single thing
  ZWJ_TAG = 0x200D

  # Find an Emoji by its :alpha_code:
  #
  # @param [String] alpha_code
  # @return [TanukiEmoji::Character]
  def self.find_by_alpha_code(alpha_code)
    index.find_by_alpha_code(alpha_code)
  end

  # Find an Emoji by its Unicode representation
  #
  # @param [String] unicode_codepoints
  # @return [TanukiEmoji::Character]
  def self.find_by_codepoints(unicode_codepoints)
    index.find_by_codepoints(unicode_codepoints)
  end

  # Index contains all known emojis
  #
  # @return [Array<TanukiEmoji::Character>]
  def self.index
    TanukiEmoji::Index.instance
  end

  # Add a new Emoji to the index
  #
  # @param [String] name
  # @param [String] codepoints
  # @param [String] alpha_code
  def self.add(name, codepoints:, alpha_code:, description:)
    emoji = Character.new(name, codepoints: codepoints, alpha_code: alpha_code, description: description)

    index.add(emoji)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tanuki_emoji-0.1.0 lib/tanuki_emoji.rb