Class: Prawn::Emoji::Image

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

Constant Summary collapse

STORE =
Emoji.root.join 'emoji', 'images'

Instance Attribute Summary collapse

Instance Method Summary collapse

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_sizeObject (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

#unicodeObject (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

#pathObject



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

def path
  STORE.join("#{unicode.codepoint}.png").to_s
end

#widthObject



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

def width
  font_size * 0.85
end