Class: OpenXml::Pptx::Parts::Slide
- Inherits:
-
OpenXml::Part
- Object
- OpenXml::Part
- OpenXml::Pptx::Parts::Slide
- Includes:
- ContainsProperties, HasAttributes, RelatablePart
- Defined in:
- lib/openxml/pptx/parts/slide.rb
Constant Summary collapse
- LAYOUT_SCHEMA =
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout".freeze
Instance Attribute Summary collapse
-
#images ⇒ Object
readonly
Returns the value of attribute images.
Attributes included from RelatablePart
Instance Method Summary collapse
- #add_image(image_part) ⇒ Object
- #background_properties ⇒ Object
- #build_image_part(path) ⇒ Object
-
#initialize(*_args) ⇒ Slide
constructor
A new instance of Slide.
-
#name ⇒ Object
Necessary for HasAttributes.
- #set_slide_layout(layout) ⇒ Object
-
#shapes ⇒ Object
Convenience accessors.
- #to_xml ⇒ Object
Methods included from RelatablePart
#add_child_part, #add_override, #add_part, #add_relationship, #content_type, #file_name, included, #indexed_path, #path, #path=, #relationship_type, #relationships, #relationships_by_path, #relationships_path
Constructor Details
#initialize(*_args) ⇒ Slide
Returns a new instance of Slide.
30 31 32 33 |
# File 'lib/openxml/pptx/parts/slide.rb', line 30 def initialize(*_args) super @images = [] end |
Instance Attribute Details
#images ⇒ Object (readonly)
Returns the value of attribute images.
8 9 10 |
# File 'lib/openxml/pptx/parts/slide.rb', line 8 def images @images end |
Instance Method Details
#add_image(image_part) ⇒ Object
40 41 42 43 44 |
# File 'lib/openxml/pptx/parts/slide.rb', line 40 def add_image(image_part) images.push(image_part) index = (parent && parent.next_image_index) || images.count add_child_part(image_part, with_index: index) end |
#background_properties ⇒ Object
70 71 72 |
# File 'lib/openxml/pptx/parts/slide.rb', line 70 def background_properties .background.background_properties end |
#build_image_part(path) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/openxml/pptx/parts/slide.rb', line 46 def build_image_part(path) path = Pathname.new(path) OpenXml::Pptx::Parts::Image.new(path.read, extension: path.extname).tap do |image| add_image(image) end end |
#name ⇒ Object
Necessary for HasAttributes
36 37 38 |
# File 'lib/openxml/pptx/parts/slide.rb', line 36 def name "slide" end |
#set_slide_layout(layout) ⇒ Object
53 54 55 |
# File 'lib/openxml/pptx/parts/slide.rb', line 53 def (layout) add_relationship layout.relationship_type, layout.path end |
#shapes ⇒ Object
Convenience accessors
66 67 68 |
# File 'lib/openxml/pptx/parts/slide.rb', line 66 def shapes .shape_tree.shapes end |
#to_xml ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/openxml/pptx/parts/slide.rb', line 57 def to_xml build_standalone_xml do |xml| xml[:p].sld(namespaces.merge(xml_attributes)) do property_xml(xml) end end end |