module EmojiData class EmojiChar def initialize(emoji_hash) # work around inconsistency in emoji.json for now by just setting a blank # array for instance value, and let it get overriden in main # deserialization loop if variable is present. @variations = [] # http://stackoverflow.com/questions/1615190/declaring-instance-variables-iterating-over-a-hash emoji_hash.each do |k,v| instance_variable_set("@#{k}",v) eigenclass = class< 0 end # return whatever is the most likely variant ID for the emojichar # for now, there can only be one, so just return first. # (in the future, there may be multiple variants, who knows!) def variant @variations.first end alias_method :to_s, :char protected def self.unified_to_char(cps) cps.split('-').map { |i| i.hex }.pack("U*") end end end