Class: Rubyword::Element::Image
- Defined in:
- lib/rubyword/element/image.rb
Instance Attribute Summary collapse
-
#images ⇒ Object
Returns the value of attribute images.
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Rubyword::Element::Base
Instance Attribute Details
#images ⇒ Object
Returns the value of attribute images.
5 6 7 |
# File 'lib/rubyword/element/image.rb', line 5 def images @images end |
Instance Method Details
#save(url, style = nil) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rubyword/element/image.rb', line 6 def save(url, style=nil) @images ||= Queue.new filename = url.split('/').last width, height = FastImage.size(url) image_params = { rid: @rubyword.init_rid, path: url, width: width, height: height, filename: filename } @images << image_params @rubyword.images << image_params @rubyword.rels_documents << { Id: "rId#{@rubyword.init_rid}", Type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image', Target: "media/#{filename}" } @rubyword.init_rid = @rubyword.init_rid + 1 end |
#write(section = nil, xml = nil) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rubyword/element/image.rb', line 27 def write(section=nil, xml=nil) @xml = xml image = self.images.pop @xml.send('w:p') { @xml.send('w:pPr') @xml.send('w:r') { @xml.send('w:pict') { @xml.send('v:shape', 'type' => '#_x0000_t75', 'style' => "width:#{image[:width]}px; height:#{image[:height]}px; margin-left:0px; margin-top:0px; mso-position-horizontal:left; mso-position-vertical:top; mso-position-horizontal-relative:char; mso-position-vertical-relative:line;") { @xml.send('w10:wrap', 'type' => 'inline', 'anchorx' => 'page', 'anchory' => 'page') @xml.send('v:imagedata', 'r:id' => "rId#{image[:rid]}", 'o:title' => '') } } } } end |