From 334c19a993e3bd0bb10d392751d9d4839a176f4f Mon Sep 17 00:00:00 2001 From: David Lilue <2525462+dvdalilue@users.noreply.github.com> Date: Wed, 21 Jul 2021 22:27:15 +0000 Subject: [PATCH] :hidden option simplification --- lib/prawn/embedded_files.rb | 2 +- lib/prawn/embedded_files/filespec.rb | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/prawn/embedded_files.rb b/lib/prawn/embedded_files.rb index 7e055ccc8..f82af36a6 100644 --- a/lib/prawn/embedded_files.rb +++ b/lib/prawn/embedded_files.rb @@ -32,7 +32,7 @@ def file(src, options = {}) filespec = Filespec.new(file_obj, options) filespec_obj = filespec.build_pdf_object(self) - unless filespec.hidden + unless filespec.hidden? # Wait for pdf-core PR # attach_file(filespec.file_name, filespec_obj) diff --git a/lib/prawn/embedded_files/filespec.rb b/lib/prawn/embedded_files/filespec.rb index 465c8459e..4311ae467 100644 --- a/lib/prawn/embedded_files/filespec.rb +++ b/lib/prawn/embedded_files/filespec.rb @@ -3,7 +3,7 @@ module Prawn module EmbeddedFiles class Filespec - attr_reader :file_name, :not_hidden + attr_reader :file_name def initialize(file, options = {}) name = options[:name] || file.chksum @@ -15,15 +15,12 @@ def initialize(file, options = {}) @description = PDF::Core::LiteralString.new(desc_str) end - if options[:hidden].nil? || options[:hidden] != true - @not_hidden = true - end - + @hidden = options[:hidden] == true @file = file end - def hidden - !@not_hidden + def hidden? + @hidden end def build_pdf_object(document)