class PdfEditor::Resource
Attributes
file[R]
Object that contains a tempfile and other pertinent info about that file, such as it's name and page count. All methods are delegated to file that aren't found in Resource
.
name[R]
Object that contains a tempfile and other pertinent info about that file, such as it's name and page count. All methods are delegated to file that aren't found in Resource
.
Public Class Methods
new(file, name=nil)
click to toggle source
# File lib/pdf_editor/resource.rb, line 17 def initialize(file, name=nil) @file = file @name = name end
Public Instance Methods
method_missing(method, *args, &b)
click to toggle source
# File lib/pdf_editor/resource.rb, line 54 def method_missing(method, *args, &b) file.send(method, *args, &b) end
open_file() { |file| ... }
click to toggle source
# File lib/pdf_editor/resource.rb, line 29 def open_file begin file.open if file.closed? yield file ensure file.close end end
page_count()
click to toggle source
# File lib/pdf_editor/resource.rb, line 42 def page_count open_file do |f| ::PDF::Reader.new(f).page_count end rescue PDF::Reader::MalformedPDFError => e raise Errors::InvalidPDFError, e.message end
read(length=nil)
click to toggle source
# File lib/pdf_editor/resource.rb, line 22 def read(length=nil) open_file do |f| f.rewind f.read(length) end end
respond_to_missing?(method_sym, include_private=false)
click to toggle source
Calls superclass method
# File lib/pdf_editor/resource.rb, line 50 def respond_to_missing?(method_sym, include_private=false) file.respond_to?(method_sym, include_private) || super end
write(contents)
click to toggle source
# File lib/pdf_editor/resource.rb, line 38 def write(contents) file.write(contents) end