Class: Axlsx::OneCellAnchor
- Inherits:
-
Object
- Object
- Axlsx::OneCellAnchor
- Defined in:
- lib/axlsx/drawing/one_cell_anchor.rb
Overview
The recommended way to manage drawings, images and charts is Worksheet#add_chart or Worksheet#add_image.
This class details a single cell anchor for drawings.
Instance Attribute Summary collapse
-
#drawing ⇒ Drawing
readonly
The drawing that holds this anchor.
-
#from ⇒ Marker
readonly
A marker that defines the from cell anchor.
-
#height ⇒ Integer
the height of the graphic object in pixels this is converted to EMU at a 92 ppi resolution.
-
#object ⇒ Pic
readonly
The object this anchor hosts.
-
#width ⇒ Integer
the width of the graphic object in pixels.
Instance Method Summary collapse
-
#index ⇒ Integer
The index of this anchor in the drawing.
-
#initialize(drawing, options = {}) ⇒ OneCellAnchor
constructor
Creates a new OneCellAnchor object and an Pic associated with it.
-
#to_xml(xml) ⇒ String
Serializes the anchor.
Constructor Details
#initialize(drawing, options = {}) ⇒ OneCellAnchor
Creates a new OneCellAnchor object and an Pic associated with it.
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 39 def initialize(drawing, ={}) @drawing = drawing @width = 0 @height = 0 drawing.anchors << self @from = Marker.new .each do |o| self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}=" end @object = Pic.new(self, ) end |
Instance Attribute Details
#drawing ⇒ Drawing (readonly)
The drawing that holds this anchor
18 19 20 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 18 def drawing @drawing end |
#from ⇒ Marker (readonly)
A marker that defines the from cell anchor. The default from column and row are 0 and 0 respectively
10 11 12 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 10 def from @from end |
#height ⇒ Integer
the height of the graphic object in pixels this is converted to EMU at a 92 ppi resolution
28 29 30 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 28 def height @height end |
#object ⇒ Pic (readonly)
The object this anchor hosts
14 15 16 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 14 def object @object end |
#width ⇒ Integer
the width of the graphic object in pixels. this is converted to EMU at a 92 ppi resolution
23 24 25 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 23 def width @width end |
Instance Method Details
#index ⇒ Integer
The index of this anchor in the drawing
59 60 61 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 59 def index @drawing.anchors.index(self) end |
#to_xml(xml) ⇒ String
Serializes the anchor
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 66 def to_xml(xml) xml[:xdr].oneCellAnchor { xml.from { from.to_xml(xml) } xml.ext ext @object.to_xml(xml) xml.clientData } end |