Class: Emoji::Character

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

Overview

:nodoc:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Character

Returns a new instance of Character.



59
60
61
62
63
# File 'lib/negarmoji/character.rb', line 59

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

Instance Attribute Details

#aliasesObject (readonly)

A list of names uniquely referring to this emoji.



17
18
19
# File 'lib/negarmoji/character.rb', line 17

def aliases
  @aliases
end

#categoryObject

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



20
21
22
# File 'lib/negarmoji/character.rb', line 20

def category
  @category
end

#descriptionObject

The Unicode description text.



23
24
25
# File 'lib/negarmoji/character.rb', line 23

def description
  @description
end

#image_filename(extension = "svg") ⇒ Object



76
77
78
79
80
81
82
# File 'lib/negarmoji/character.rb', line 76

def image_filename(extension = "svg")
  if defined? @image_filename
    @image_filename
  else
    default_image_filename(extension)
  end
end

#ios_versionObject

The iOS version where this emoji first debuted.



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

def ios_version
  @ios_version
end

#tagsObject (readonly)

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



53
54
55
# File 'lib/negarmoji/character.rb', line 53

def tags
  @tags
end

#unicode_aliasesObject (readonly)

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



40
41
42
# File 'lib/negarmoji/character.rb', line 40

def unicode_aliases
  @unicode_aliases
end

#unicode_versionObject

The Unicode spec version where this emoji first debuted.



26
27
28
# File 'lib/negarmoji/character.rb', line 26

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.



7
8
9
# File 'lib/negarmoji/character.rb', line 7

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



35
36
37
# File 'lib/negarmoji/character.rb', line 35

def add_alias(name)
  aliases << name
end

#add_tag(tag) ⇒ Object



55
56
57
# File 'lib/negarmoji/character.rb', line 55

def add_tag(tag)
  tags << tag
end

#add_unicode_alias(str) ⇒ Object



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

def add_unicode_alias(str)
  unicode_aliases << str
end

#custom?Boolean

True if the emoji is not a standard Emoji character.

Returns:

  • (Boolean)


12
13
14
# File 'lib/negarmoji/character.rb', line 12

def custom?
  !raw
end

#hex_inspectObject



70
71
72
# File 'lib/negarmoji/character.rb', line 70

def hex_inspect
  self.class.hex_inspect(raw)
end

#inspectObject



65
66
67
68
# File 'lib/negarmoji/character.rb', line 65

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

#nameObject



31
32
33
# File 'lib/negarmoji/character.rb', line 31

def name
  aliases.first
end

#rawObject

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



43
44
45
# File 'lib/negarmoji/character.rb', line 43

def raw
  unicode_aliases.first
end