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_string(str = '') ⇒ String
Serializes the object.
Constructor Details
#initialize(drawing, options = {}) ⇒ OneCellAnchor
Creates a new OneCellAnchor object and an Pic associated with it.
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 40 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
19 20 21 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 19 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
11 12 13 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 11 def from @from end |
#height ⇒ Integer
the height of the graphic object in pixels this is converted to EMU at a 92 ppi resolution
29 30 31 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 29 def height @height end |
#object ⇒ Pic (readonly)
The object this anchor hosts
15 16 17 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 15 def object @object end |
#width ⇒ Integer
the width of the graphic object in pixels. this is converted to EMU at a 92 ppi resolution
24 25 26 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 24 def width @width end |
Instance Method Details
#index ⇒ Integer
The index of this anchor in the drawing
60 61 62 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 60 def index @drawing.anchors.index(self) end |
#to_xml_string(str = '') ⇒ String
Serializes the object
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 68 def to_xml_string(str = '') str << '<xdr:oneCellAnchor>' str << '<xdr:from>' from.to_xml_string(str) str << '</xdr:from>' str << '<xdr:ext cx="' << ext[:cx].to_s << '" cy="' << ext[:cy].to_s << '"/>' @object.to_xml_string(str) str << '<xdr:clientData/>' str << '</xdr:oneCellAnchor>' end |