Class: Prawn::Emoji::Image
- Inherits:
-
Object
- Object
- Prawn::Emoji::Image
- Defined in:
- lib/prawn/emoji/image.rb
Constant Summary collapse
- STORE =
Emoji.root.join 'emoji', 'images'
Instance Attribute Summary collapse
-
#font_size ⇒ Object
readonly
Returns the value of attribute font_size.
-
#unicode ⇒ Object
readonly
Returns the value of attribute unicode.
Instance Method Summary collapse
- #adjust_x(base_x) ⇒ Object
- #adjust_y(base_y) ⇒ Object
-
#initialize(unicode, font_size) ⇒ Image
constructor
A new instance of Image.
- #path ⇒ Object
- #width ⇒ Object
Constructor Details
#initialize(unicode, font_size) ⇒ Image
Returns a new instance of Image.
13 14 15 16 |
# File 'lib/prawn/emoji/image.rb', line 13 def initialize(unicode, font_size) @unicode = unicode @font_size = font_size end |
Instance Attribute Details
#font_size ⇒ Object (readonly)
Returns the value of attribute font_size.
11 12 13 |
# File 'lib/prawn/emoji/image.rb', line 11 def font_size @font_size end |
#unicode ⇒ Object (readonly)
Returns the value of attribute unicode.
11 12 13 |
# File 'lib/prawn/emoji/image.rb', line 11 def unicode @unicode end |
Instance Method Details
#adjust_x(base_x) ⇒ Object
22 23 24 |
# File 'lib/prawn/emoji/image.rb', line 22 def adjust_x(base_x) base_x + (font_size - width) / 2 end |
#adjust_y(base_y) ⇒ Object
26 27 28 |
# File 'lib/prawn/emoji/image.rb', line 26 def adjust_y(base_y) base_y + font_size * 0.8 end |
#path ⇒ Object
18 19 20 |
# File 'lib/prawn/emoji/image.rb', line 18 def path STORE.join("#{unicode.codepoint}.png").to_s end |
#width ⇒ Object
30 31 32 |
# File 'lib/prawn/emoji/image.rb', line 30 def width font_size * 0.85 end |