Class: ODFWriter::ImageReader

Inherits:
Object
  • Object
show all
Defined in:
lib/odf_writer/image_reader.rb

Overview

ImageReader: find all images and set name

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ ImageReader

initialize



38
39
40
# File 'lib/odf_writer/image_reader.rb', line 38

def initialize(opts)
  @name = opts[:name]
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



31
32
33
# File 'lib/odf_writer/image_reader.rb', line 31

def name
  @name
end

Instance Method Details

#paths(root, doc) ⇒ Object

get_paths: limit to paths with ancestors ‘text ’(content.xml) and master-styles (styles.xml)



47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/odf_writer/image_reader.rb', line 47

def paths( root, doc)
  
  # find nodes with matching field elements matching [BOOKMARK] pattern
  nodes = doc.xpath("//draw:frame[draw:image]").select{|node| scan(node).present? }
  
  # find path for each field
  paths = nil
  nodes.each do |node|
    leaf  = {:images => scan(node)}
    paths = PathFinder.trail(node, leaf, :root => root, :paths => paths)
  end #each
  paths.to_h
  
end