Sha256: b4c4832eacca84e4c46c4edd18dcb35a5e8340c4270252051734f2cc3ee0d3e8
Contents?: true
Size: 951 Bytes
Versions: 2
Compression:
Stored size: 951 Bytes
Contents
# frozen_string_literal: true require 'forwardable' module Prawn module Emoji class Image extend Forwardable STORE = Emoji.root.join 'emoji', 'images' def_delegators :emoji_char, :width, :height def initialize(emoji_char) @emoji_char = emoji_char end def render(document, at:) x, y = at position = [x, y + height] if Prawn::VERSION >= '2.3.0' document.image(path, at: position, width: width) else # Prawn 2.2 does not close the image file when Pathname is passed to Document#image method. # https://github.com/prawnpdf/prawn/pull/1090 File.open(path, 'rb') do |image_file| document.image(image_file, at: position, width: width) end end end def path STORE.join("#{emoji_char.codepoint}.png").to_s end private attr_reader :emoji_char end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
prawn-emoji-4.2.0 | lib/prawn/emoji/image.rb |
prawn-emoji-4.1.0 | lib/prawn/emoji/image.rb |