Class: Axlsx::TwoCellAnchor
- Inherits:
-
Object
- Object
- Axlsx::TwoCellAnchor
- Defined in:
- lib/axlsx/drawing/two_cell_anchor.rb
Overview
The recommended way to manage drawings and charts is Worksheet#add_chart. Anchors are specified by the :start_at and :end_at options to that method.
This class details the anchor points 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.
-
#graphic_frame ⇒ GraphicFrame
readonly
The frame for your chart.
-
#index ⇒ Integer
readonly
The index of this anchor in the drawing.
-
#to ⇒ Marker
readonly
A marker that returns the to cell anchor.
Instance Method Summary collapse
-
#end_at(x, y) ⇒ Marker
This is a short cut method to set the end anchor position.
-
#initialize(drawing, chart_type, options) ⇒ TwoCellAnchor
constructor
Creates a new TwoCellAnchor object.
-
#start_at(x, y) ⇒ Marker
This is a short cut method to set the start anchor position.
-
#to_xml(xml) ⇒ String
Serializes the two cell anchor.
Constructor Details
#initialize(drawing, chart_type, options) ⇒ TwoCellAnchor
Creates a new TwoCellAnchor object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 31 def initialize(drawing, chart_type, ) @drawing = drawing drawing.anchors << self @from, @to = Marker.new, Marker.new(:col => 5, :row=>10) @graphic_frame = GraphicFrame.new(self, chart_type, ) self.start_at([:start_at][0], [:start_at][1]) if [:start_at].is_a?(Array) self.end_at([:end_at][0], [:end_at][1]) if [:end_at].is_a?(Array) # passing a reference to our start and end markers for convenience # this lets us access the markers directly from the chart. @graphic_frame.chart.send(:start_at=, @from) @graphic_frame.chart.send(:end_at=, @to) end |
Instance Attribute Details
#drawing ⇒ Drawing (readonly)
The drawing that holds this anchor
20 21 22 |
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 20 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
9 10 11 |
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 9 def from @from end |
#graphic_frame ⇒ GraphicFrame (readonly)
The frame for your chart
16 17 18 |
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 16 def graphic_frame @graphic_frame end |
#index ⇒ Integer (readonly)
The index of this anchor in the drawing
24 25 26 |
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 24 def index @index end |
#to ⇒ Marker (readonly)
A marker that returns the to cell anchor. The default to column and row are 5 and 10 respectively
12 13 14 |
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 12 def to @to end |
Instance Method Details
#end_at(x, y) ⇒ Marker
This is a short cut method to set the end anchor position
65 66 67 68 69 |
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 65 def end_at(x, y) @to.col = x @to.row = y @to end |
#start_at(x, y) ⇒ Marker
This is a short cut method to set the start anchor position
55 56 57 58 59 |
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 55 def start_at(x, y) @from.col = x @from.row = y @from end |
#to_xml(xml) ⇒ String
Serializes the two cell anchor
74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 74 def to_xml(xml) #build it for now, break it down later! xml.send('xdr:twoCellAnchor') { xml.send('xdr:from') { from.to_xml(xml) } xml.send('xdr:to') { to.to_xml(xml) } @graphic_frame.to_xml(xml) xml.send('xdr:clientData') } end |