Class: Rbpptx::Slide
- Inherits:
-
Object
- Object
- Rbpptx::Slide
- Defined in:
- lib/rbpptx/slide.rb
Overview
A single slide loaded from a presentation’s ZIP container.
Parsing of the slide’s XML payload is deferred until #shapes is first called and then cached, so simply enumerating slides via Presentation#slides does not pay the per-slide parse cost.
Constant Summary collapse
- P_NS =
"http://schemas.openxmlformats.org/presentationml/2006/main".freeze
Instance Attribute Summary collapse
-
#part_name ⇒ String
readonly
The part name of the slide inside the package, e.g.
Instance Method Summary collapse
- #clear_dirty! ⇒ Object private
-
#dirty? ⇒ Boolean
Whether any shape on this slide has been mutated since load.
-
#initialize(zip:, part_name:) ⇒ Slide
constructor
A new instance of Slide.
-
#mark_dirty! ⇒ Object
private
Marks the slide as dirty.
-
#name ⇒ String
The slide’s basename without extension, e.g.
-
#shapes ⇒ Array<Shape>
<p:sp> children of the slide’s shape tree, in document order.
-
#to_xml ⇒ String
The slide’s XML, reflecting any in-memory mutations.
Constructor Details
#initialize(zip:, part_name:) ⇒ Slide
Returns a new instance of Slide.
16 17 18 19 20 |
# File 'lib/rbpptx/slide.rb', line 16 def initialize(zip:, part_name:) @zip = zip @part_name = part_name @dirty = false end |
Instance Attribute Details
#part_name ⇒ String (readonly)
Returns the part name of the slide inside the package, e.g. “ppt/slides/slide1.xml”.
12 13 14 |
# File 'lib/rbpptx/slide.rb', line 12 def part_name @part_name end |
Instance Method Details
#clear_dirty! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
54 55 56 |
# File 'lib/rbpptx/slide.rb', line 54 def clear_dirty! @dirty = false end |
#dirty? ⇒ Boolean
Returns whether any shape on this slide has been mutated since load.
35 36 37 |
# File 'lib/rbpptx/slide.rb', line 35 def dirty? @dirty end |
#mark_dirty! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Marks the slide as dirty. Called by Rbpptx::Shape setters; not part of the public API.
43 44 45 |
# File 'lib/rbpptx/slide.rb', line 43 def mark_dirty! @dirty = true end |
#name ⇒ String
Returns the slide’s basename without extension, e.g. “slide1”.
23 24 25 |
# File 'lib/rbpptx/slide.rb', line 23 def name File.basename(@part_name, ".xml") end |
#shapes ⇒ Array<Shape>
Returns <p:sp> children of the slide’s shape tree, in document order.
29 30 31 |
# File 'lib/rbpptx/slide.rb', line 29 def shapes @shapes ||= build_shapes end |
#to_xml ⇒ String
Returns the slide’s XML, reflecting any in-memory mutations. The XML declaration is preserved.
49 50 51 |
# File 'lib/rbpptx/slide.rb', line 49 def to_xml doc.to_xml end |