Class: Prawn::Emoji::Char
- Inherits:
-
Object
- Object
- Prawn::Emoji::Char
- Defined in:
- lib/prawn/emoji/char.rb
Constant Summary collapse
- VARIATION_SELECTORS =
%w(fe0e fe0f).freeze
Instance Attribute Summary collapse
-
#char ⇒ Object
(also: #to_s)
readonly
Returns the value of attribute char.
-
#font_size ⇒ Object
readonly
Returns the value of attribute font_size.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #codepoint ⇒ Object
- #height ⇒ Object
-
#initialize(char, font_size) ⇒ Char
constructor
A new instance of Char.
- #width ⇒ Object
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
#char ⇒ Object (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_size ⇒ Object (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 |
#codepoint ⇒ Object
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 |
#height ⇒ Object
34 35 36 |
# File 'lib/prawn/emoji/char.rb', line 34 def height @height ||= font_size * 0.8 end |
#width ⇒ Object
30 31 32 |
# File 'lib/prawn/emoji/char.rb', line 30 def width @width ||= font_size * 0.85 end |