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 28 |
# 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 start_at(*[:start_at]) if [:start_at] @object = Pic.new(self, ) end |
Instance Attribute Details
#drawing ⇒ Drawing (readonly)
The drawing that holds this anchor
40 41 42 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 40 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
32 33 34 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 32 def from @from end |
#height ⇒ Integer
the height of the graphic object in pixels this is converted to EMU at a 92 ppi resolution
50 51 52 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 50 def height @height end |
#object ⇒ Pic (readonly)
The object this anchor hosts
36 37 38 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 36 def object @object end |
#width ⇒ Integer
the width of the graphic object in pixels. this is converted to EMU at a 92 ppi resolution
45 46 47 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 45 def width @width end |
Instance Method Details
#index ⇒ Integer
The index of this anchor in the drawing
76 77 78 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 76 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.
57 58 59 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 57 def start_at(x, y = 0) from.coord x, y end |
#to_xml_string(str = +'')) ⇒ String
Serializes the object
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/axlsx/drawing/one_cell_anchor.rb', line 83 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 |