Class: Prawn::Attachment::Filespec
- Inherits:
-
Object
- Object
- Prawn::Attachment::Filespec
- Defined in:
- lib/prawn/attachment/filespec.rb
Overview
FileSpec corresponds to the PDF file specification object.
Instance Attribute Summary collapse
-
#file_name ⇒ Object
readonly
Returns the value of attribute file_name.
Instance Method Summary collapse
- #build_pdf_object(document) ⇒ Object
- #hidden? ⇒ Boolean
-
#initialize(file, options = {}) ⇒ Filespec
constructor
A new instance of Filespec.
Constructor Details
#initialize(file, options = {}) ⇒ Filespec
Returns a new instance of Filespec.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/prawn/attachment/filespec.rb', line 11 def initialize(file, = {}) hexdigest = Digest.hexencode(file.data[:Params][:CheckSum]) name = [:name] || hexdigest @file_name = PDF::Core::LiteralString.new(name) if [:description] desc_str = [:description].to_s @description = PDF::Core::LiteralString.new(desc_str) end @hidden = [:hidden] @file = file end |
Instance Attribute Details
#file_name ⇒ Object (readonly)
Returns the value of attribute file_name.
9 10 11 |
# File 'lib/prawn/attachment/filespec.rb', line 9 def file_name @file_name end |
Instance Method Details
#build_pdf_object(document) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/prawn/attachment/filespec.rb', line 30 def build_pdf_object(document) obj = document.ref!( Type: :Filespec, F: file_name, EF: { F: file, UF: file }, UF: file_name ) obj.data[:Desc] = description if description obj end |
#hidden? ⇒ Boolean
26 27 28 |
# File 'lib/prawn/attachment/filespec.rb', line 26 def hidden? @hidden end |