Class: Axlsx::OneCellAnchor
- Inherits:
-
Object
- Object
- Axlsx::OneCellAnchor
- Includes:
- OptionsParser
- 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.
-
#start_at(x, y = 0) ⇒ Object
sets the starting position for the anchor.
-
#to_xml_string(str = '') ⇒ String
Serializes the object.
Methods included from OptionsParser
Constructor Details
#initialize(drawing, options = {}) ⇒ OneCellAnchor
Creates a new OneCellAnchor object and an Pic associated with it.
19 20 21 22 23 24 25 26 27 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 19 def initialize(drawing, ={}) @drawing = drawing @width = 0 @height = 0 drawing.anchors << self @from = Marker.new @object = Pic.new(self, ) end |
Instance Attribute Details
#drawing ⇒ Drawing (readonly)
The drawing that holds this anchor
39 40 41 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 39 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
31 32 33 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 31 def from @from end |
#height ⇒ Integer
the height of the graphic object in pixels this is converted to EMU at a 92 ppi resolution
49 50 51 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 49 def height @height end |
#object ⇒ Pic (readonly)
The object this anchor hosts
35 36 37 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 35 def object @object end |
#width ⇒ Integer
the width of the graphic object in pixels. this is converted to EMU at a 92 ppi resolution
44 45 46 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 44 def width @width end |
Instance Method Details
#index ⇒ Integer
The index of this anchor in the drawing
68 69 70 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 68 def index @drawing.anchors.index(self) end |
#start_at(x, y = 0) ⇒ Object
sets the starting position for the anchor. You can provide a String like "A1", an array like [0,0] or a cell object for the x parameter. We just 'figure it out' for you.
56 57 58 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 56 def start_at(x, y=0) from.coord x, y end |
#to_xml_string(str = '') ⇒ String
Serializes the object
75 76 77 78 79 80 81 82 83 84 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 75 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 |