Class: Prawn::Emoji::Char

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

Constant Summary collapse

VARIATION_SELECTORS =
%w(fe0e fe0f).freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(char, font_size) ⇒ Char

Returns a new instance of Char.



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

def initialize(char, font_size)
  @char = char
  @font_size = font_size
end

Instance Attribute Details

#charObject (readonly) Also known as: to_s

Returns the value of attribute char.



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

def char
  @char
end

#font_sizeObject (readonly)

Returns the value of attribute font_size.



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

def font_size
  @font_size
end

Class Method Details

.format_codepoint(codepoints) ⇒ Object



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

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

Instance Method Details

#==(other) ⇒ Object



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

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

#codepointObject



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

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

#heightObject



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

def height
  @height ||= font_size * 0.8
end

#widthObject



30
31
32
# File 'lib/prawn/emoji/char.rb', line 30

def width
  @width ||= font_size * 0.85
end