Class: Odf::Element::Image

Inherits:
Abstract show all
Defined in:
lib/odf/element/image.rb

Constant Summary collapse

VALID_OPTIONS =
{
  filter_name: 'draw:filter-name',
  actuate:     'xlink:actuate',
  href:        'xlink:href',
  show:        'xlink:show',
  type:        'xlink:type',
  xml_id:      'xml:id'
}
XML_TAG =
'draw:image'.freeze

Instance Attribute Summary

Attributes inherited from Abstract

#parent, #root

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Abstract

#document, #valid_options, #xml_tag

Constructor Details

#initialize(parent, options) ⇒ Image

Returns a new instance of Image.



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/odf/element/image.rb', line 19

def initialize(parent, options)
  @parent = parent

  # Save image under Pictures directory
  if options.fetch(:save, true) && options[:href]
    uri = save_image(options[:href])
    options.merge!({ href: uri, show: 'embed' })
  end

  super(parent, options)
end

Class Method Details

.build(parent, options = {}) ⇒ Object



15
16
17
# File 'lib/odf/element/image.rb', line 15

def self.build(parent, options = {})
  new(parent, options)
end

Instance Method Details

#add_paragraph(text, options = {}) ⇒ Object



31
32
33
# File 'lib/odf/element/image.rb', line 31

def add_paragraph(text, options = {})
  Odf::Element::Paragraph.build(self, text, options)
end