Class: Prawn::Attachment::EmbeddedFile
- Inherits:
-
Object
- Object
- Prawn::Attachment::EmbeddedFile
- Defined in:
- lib/prawn/attachment/embedded_file.rb
Overview
EmbeddedFile represents a file to be embedded in the PDF.
Instance Attribute Summary collapse
-
#checksum ⇒ Object
readonly
Returns the value of attribute checksum.
-
#creation_date ⇒ Object
readonly
Returns the value of attribute creation_date.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#modification_date ⇒ Object
readonly
Returns the value of attribute modification_date.
Instance Method Summary collapse
- #build_pdf_object(document) ⇒ Object
-
#initialize(data, options = {}) ⇒ EmbeddedFile
constructor
A new instance of EmbeddedFile.
Constructor Details
#initialize(data, options = {}) ⇒ EmbeddedFile
Returns a new instance of EmbeddedFile.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/prawn/attachment/embedded_file.rb', line 9 def initialize(data, = {}) @data = data @creation_date = [:creation_date] @creation_date = Time.now.utc unless @creation_date.is_a?(Time) @modification_date = [:modification_date] @modification_date = Time.now.utc unless @modification_date.is_a?(Time) @checksum = Digest::MD5.digest(data) end |
Instance Attribute Details
#checksum ⇒ Object (readonly)
Returns the value of attribute checksum.
7 8 9 |
# File 'lib/prawn/attachment/embedded_file.rb', line 7 def checksum @checksum end |
#creation_date ⇒ Object (readonly)
Returns the value of attribute creation_date.
7 8 9 |
# File 'lib/prawn/attachment/embedded_file.rb', line 7 def creation_date @creation_date end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
7 8 9 |
# File 'lib/prawn/attachment/embedded_file.rb', line 7 def data @data end |
#modification_date ⇒ Object (readonly)
Returns the value of attribute modification_date.
7 8 9 |
# File 'lib/prawn/attachment/embedded_file.rb', line 7 def modification_date @modification_date end |
Instance Method Details
#build_pdf_object(document) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/prawn/attachment/embedded_file.rb', line 21 def build_pdf_object(document) obj = document.ref!(reference_params) obj << data obj.stream.compress! if document.compression_enabled? obj end |