Class: Prawn::Emoji::Unicode

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

Constant Summary collapse

VARIATION_SELECTORS =
%w(fe0e fe0f).freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(char) ⇒ Unicode

Returns a new instance of Unicode.



14
15
16
# File 'lib/prawn/emoji/unicode.rb', line 14

def initialize(char)
  @unicode = char
end

Class Method Details

.format_codepoint(codepoints) ⇒ Object



9
10
11
# File 'lib/prawn/emoji/unicode.rb', line 9

def format_codepoint(codepoints)
  (codepoints - VARIATION_SELECTORS).map { |c| c.rjust(4, '0') }.join('-').downcase
end

Instance Method Details

#==(other) ⇒ Object



18
19
20
# File 'lib/prawn/emoji/unicode.rb', line 18

def ==(other)
  to_s == other.to_s
end

#codepointObject



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

def codepoint
  @codepoint ||= self.class.format_codepoint(@unicode.codepoints.map { |c| c.to_s(16) })
end

#to_sObject



26
27
28
# File 'lib/prawn/emoji/unicode.rb', line 26

def to_s
  @unicode
end