Class: Prawn::Emoji::Unicode

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

Constant Summary collapse

VARIATION_SELECTORS =
{
  text:  '\ufe0e',
  emoji: '\ufe0f'
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(char) ⇒ Unicode

Returns a new instance of Unicode.



11
12
13
14
# File 'lib/prawn/emoji/unicode.rb', line 11

def initialize(char)
  @present_as_text = !!char.match(VARIATION_SELECTORS[:text])
  @unicode = delete_variation_selector(char)
end

Instance Method Details

#==(other) ⇒ Object



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

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

#codepointObject



20
21
22
# File 'lib/prawn/emoji/unicode.rb', line 20

def codepoint
  @codepoint ||= @unicode.codepoints.map { |c| '%04x' % c.to_s }.join('-').downcase
end

#text?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/prawn/emoji/unicode.rb', line 24

def text?
  @present_as_text
end

#to_sObject



28
29
30
# File 'lib/prawn/emoji/unicode.rb', line 28

def to_s
  @unicode
end