Class: Docxer::Word::Contents::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/docxer/word/contents/image.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(media, options = {}) ⇒ Image

Returns a new instance of Image.



8
9
10
11
12
# File 'lib/docxer/word/contents/image.rb', line 8

def initialize(media, options={})
  @media = media
  @media.file.rewind
  @options = options
end

Instance Attribute Details

#mediaObject

Returns the value of attribute media.



7
8
9
# File 'lib/docxer/word/contents/image.rb', line 7

def media
  @media
end

#optionsObject

Returns the value of attribute options.



7
8
9
# File 'lib/docxer/word/contents/image.rb', line 7

def options
  @options
end

Instance Method Details

#render(xml) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/docxer/word/contents/image.rb', line 20

def render(xml)
  xml['w'].r do
    xml['w'].rPr do
      xml['w'].noProof
    end
    xml['w'].pict do
      xml['v'].shape( 'id' => @media.uniq_id, 'type' => @media.type, 'style' => styles ) do
        xml['v'].imagedata( 'r:id' => @media.sequence, 'o:title' => @options[:title] )
      end
    end
    xml['w'].rPr do
      xml['w'].noProof
    end
  end
end

#stylesObject



14
15
16
17
18
# File 'lib/docxer/word/contents/image.rb', line 14

def styles
  if @options[:style]
    @options[:style].collect{|k, v| [k, v].join(':')}.join(';')
  end
end