Class: Pdfrb::Model::Type::DPart

Inherits:
Cos::Dictionary show all
Defined in:
lib/pdfrb/model/type/d_part.rb

Overview

DPart (ISO 16612-2 PDF/VT §6.3.5). One node in the Document Part hierarchy. Either has /DParts (a tree of child DParts) or /Start + /End pointing to the page range it covers.

Instance Attribute Summary

Attributes inherited from Object

#document, #gen, #oid, #value

Instance Method Summary collapse

Methods inherited from Cos::Dictionary

#[], #[]=, arlington_available?, arlington_default, arlington_key_to_symbol, arlington_loaded_for?, arlington_mark_loaded, arlington_object, arlington_one_type_to_ruby, arlington_required?, arlington_types_to_ruby, arlington_version, define_field, define_field_from_arlington, #delete, #each, each_field, #each_raw, #empty?, field, #initialize, #key?, #keys, lookup_type, merged_field, own_fields, #pdf_type, register_type, type_map, #validate

Methods inherited from Object

#==, define_type, #deref, #indirect?, #initialize, #must_be_indirect?, #pdf_type, pdf_type

Constructor Details

This class inherits a constructor from Pdfrb::Model::Cos::Dictionary

Instance Method Details

#child_partsObject

/DParts — array of arrays of child DParts. Mutually exclusive with /Start + /End.



65
66
67
# File 'lib/pdfrb/model/type/d_part.rb', line 65

def child_parts
  value[:DParts]
end

#end_page(document = nil) ⇒ Object

/End — indirect ref to the last Page in this part.



78
79
80
81
82
83
# File 'lib/pdfrb/model/type/d_part.rb', line 78

def end_page(document = nil)
  ref = value[:End]
  return nil unless ref && document

  ref.is_a?(Pdfrb::Model::Reference) ? document.object(ref) : ref
end

#leaf?Boolean

Returns:

  • (Boolean)


85
86
87
# File 'lib/pdfrb/model/type/d_part.rb', line 85

def leaf?
  child_parts.nil?
end

#parent(document = nil) ⇒ Object

/Parent — required indirect ref to the containing DPart or DPartRoot (may be absent when Metadata is present).



56
57
58
59
60
61
# File 'lib/pdfrb/model/type/d_part.rb', line 56

def parent(document = nil)
  ref = value[:Parent]
  return nil unless ref && document

  ref.is_a?(Pdfrb::Model::Reference) ? document.object(ref) : ref
end

#start_page(document = nil) ⇒ Object

/Start — indirect ref to the first Page in this part.



70
71
72
73
74
75
# File 'lib/pdfrb/model/type/d_part.rb', line 70

def start_page(document = nil)
  ref = value[:Start]
  return nil unless ref && document

  ref.is_a?(Pdfrb::Model::Reference) ? document.object(ref) : ref
end

#typeObject

/Type — optional, fixed "DPart".



50
51
52
# File 'lib/pdfrb/model/type/d_part.rb', line 50

def type
  value[:Type]&.to_sym
end