Class: Pdfrb::Destination::Fit
- Inherits:
-
Object
- Object
- Pdfrb::Destination::Fit
- Defined in:
- lib/pdfrb/destination/fit.rb
Overview
Destination fit types (ISO 32000-2 ยง12.3.2.2). Each type specifies how the page should be displayed when navigated to.
OCP: new fit type = subclass + register_as.
Direct Known Subclasses
FitBoundingBox, FitBoundingBoxHorizontal, FitBoundingBoxVertical, FitHorizontal, FitRectangle, FitVertical, FullPage, XYZ
Instance Attribute Summary collapse
-
#page_ref ⇒ Object
readonly
Returns the value of attribute page_ref.
Class Method Summary collapse
- .[](name) ⇒ Object
- .fit_keyword ⇒ Object
- .register(name, klass) ⇒ Object
- .register_as(name = fit_keyword) ⇒ Object
- .registry ⇒ Object
- .types ⇒ Object
Instance Method Summary collapse
-
#initialize(page_ref) ⇒ Fit
constructor
A new instance of Fit.
-
#to_pdf ⇒ Pdfrb::Model::PdfArray
Serialize to the PDF destination array form.
Constructor Details
#initialize(page_ref) ⇒ Fit
Returns a new instance of Fit.
39 40 41 |
# File 'lib/pdfrb/destination/fit.rb', line 39 def initialize(page_ref) @page_ref = page_ref end |
Instance Attribute Details
#page_ref ⇒ Object (readonly)
Returns the value of attribute page_ref.
37 38 39 |
# File 'lib/pdfrb/destination/fit.rb', line 37 def page_ref @page_ref end |
Class Method Details
.[](name) ⇒ Object
19 20 21 |
# File 'lib/pdfrb/destination/fit.rb', line 19 def [](name) registry[name.to_sym] end |
.fit_keyword ⇒ Object
27 28 29 |
# File 'lib/pdfrb/destination/fit.rb', line 27 def fit_keyword raise NotImplementedError end |
.register(name, klass) ⇒ Object
15 16 17 |
# File 'lib/pdfrb/destination/fit.rb', line 15 def register(name, klass) registry[name.to_sym] = klass end |
.register_as(name = fit_keyword) ⇒ Object
31 32 33 34 |
# File 'lib/pdfrb/destination/fit.rb', line 31 def register_as(name = fit_keyword) Fit.register(name, self) self end |
.registry ⇒ Object
11 12 13 |
# File 'lib/pdfrb/destination/fit.rb', line 11 def registry @registry ||= {} end |
.types ⇒ Object
23 24 25 |
# File 'lib/pdfrb/destination/fit.rb', line 23 def types registry.keys end |
Instance Method Details
#to_pdf ⇒ Pdfrb::Model::PdfArray
Serialize to the PDF destination array form.
45 46 47 |
# File 'lib/pdfrb/destination/fit.rb', line 45 def to_pdf Pdfrb::Model::PdfArray.new([@page_ref, self.class.fit_keyword]) end |