Class: Emoji::Character

Inherits:
Object
  • Object
show all
Defined in:
lib/emoji/character.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Character

Returns a new instance of Character.



51
52
53
54
55
# File 'lib/emoji/character.rb', line 51

def initialize(name)
  @aliases = Array(name)
  @unicode_aliases = []
  @tags = []
end

Instance Attribute Details

#aliasesObject (readonly)

A list of names uniquely referring to this emoji.



13
14
15
# File 'lib/emoji/character.rb', line 13

def aliases
  @aliases
end

#categoryObject

The category for this emoji as per Apple’s character palette



16
17
18
# File 'lib/emoji/character.rb', line 16

def category
  @category
end

#descriptionObject

The Unicode description text



19
20
21
# File 'lib/emoji/character.rb', line 19

def description
  @description
end

#image_filenameObject



68
69
70
71
72
73
74
# File 'lib/emoji/character.rb', line 68

def image_filename
  if defined? @image_filename
    @image_filename
  else
    default_image_filename
  end
end

#ios_versionObject

The iOS version where this emoji first debuted



25
26
27
# File 'lib/emoji/character.rb', line 25

def ios_version
  @ios_version
end

#tagsObject (readonly)

A list of tags associated with an emoji. Multiple emojis can share the same tags.



45
46
47
# File 'lib/emoji/character.rb', line 45

def tags
  @tags
end

#unicode_aliasesObject (readonly)

A list of Unicode strings that uniquely refer to this emoji.



34
35
36
# File 'lib/emoji/character.rb', line 34

def unicode_aliases
  @unicode_aliases
end

#unicode_versionObject

The Unicode spec version where this emoji first debuted



22
23
24
# File 'lib/emoji/character.rb', line 22

def unicode_version
  @unicode_version
end

Class Method Details

.hex_inspect(str) ⇒ Object

Inspect individual Unicode characters in a string by dumping its codepoints in hexadecimal format.



5
6
7
# File 'lib/emoji/character.rb', line 5

def self.hex_inspect(str)
  str.codepoints.map { |c| c.to_s(16).rjust(4, '0') }.join('-')
end

Instance Method Details

#add_alias(name) ⇒ Object



29
30
31
# File 'lib/emoji/character.rb', line 29

def add_alias(name)
  aliases << name
end

#add_tag(tag) ⇒ Object



47
48
49
# File 'lib/emoji/character.rb', line 47

def add_tag(tag)
  tags << tag
end

#add_unicode_alias(str) ⇒ Object



39
40
41
# File 'lib/emoji/character.rb', line 39

def add_unicode_alias(str)
  unicode_aliases << str
end

#custom?Boolean

True if the emoji is not a standard Emoji character.

Returns:

  • (Boolean)


10
# File 'lib/emoji/character.rb', line 10

def custom?() !raw end

#hex_inspectObject



62
63
64
# File 'lib/emoji/character.rb', line 62

def hex_inspect
  self.class.hex_inspect(raw)
end

#inspectObject



57
58
59
60
# File 'lib/emoji/character.rb', line 57

def inspect
  hex = '(%s)' % hex_inspect unless custom?
  %(#<#{self.class.name}:#{name}#{hex}>)
end

#nameObject



27
# File 'lib/emoji/character.rb', line 27

def name() aliases.first end

#rawObject

Raw Unicode string for an emoji. Nil if emoji is non-standard.



37
# File 'lib/emoji/character.rb', line 37

def raw() unicode_aliases.first end