Sha256: b4d5c7fe77b60f981abb8ebd83e7b205eb12bf4560701ad0c274923e025069d2
Contents?: true
Size: 1.14 KB
Versions: 7
Compression:
Stored size: 1.14 KB
Contents
require_relative 'emoji/asset_information' module Emojidex # emoji base class class Emoji attr_accessor :moji, :category, :code, :code_ja, :unicode, :tags, :emoticon include Emojidex::EmojiAssetInformation def initialize(details = {}) @moji = details[:moji] @code, @code_ja = details[:code], details[:code_ja] @unicode, @full_name = details[:unicode], details[:full_name] @emoticon = details[:emoticon] @category = details[:category] ? details[:category].to_sym : :other @tags = details[:tags].map { |tag| tag.to_sym } unless details[:tags].nil? @link = details[:link] @is_wide = details[:is_wide] end def to_s @moji || ":#{@code}:" end def to_json(*args) to_hash.to_json(*args) end def to_hash hash = {} instance_variables.each do |key| hash[key.to_s.delete('@')] = instance_variable_get(key) end hash end def [](key) instance_variable_get(key.to_s.delete(':').insert(0, '@')) end def []=(key, val) instance_variable_set(key.to_s.delete(':').insert(0, '@'), val) end end end
Version data entries
7 entries across 7 versions & 1 rubygems