class Odf::Element::Image

Constants

VALID_OPTIONS
XML_TAG

Public Class Methods

build(parent, options = {}) click to toggle source
# File lib/odf/element/image.rb, line 15
def self.build(parent, options = {})
  new(parent, options)
end
new(parent, options) click to toggle source
Calls superclass method Odf::Element::Abstract::new
# 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

Public Instance Methods

add_paragraph(text, options = {}) click to toggle source
# File lib/odf/element/image.rb, line 31
def add_paragraph(text, options = {})
  Odf::Element::Paragraph.build(self, text, options)
end

Private Instance Methods

save_image(href) click to toggle source
# File lib/odf/element/image.rb, line 36
def save_image(href)
  document.add_image(href)
end