Class: Axlsx::TwoCellAnchor
- Inherits:
-
Object
- Object
- Axlsx::TwoCellAnchor
- Includes:
- OptionsParser
- 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.
-
#object ⇒ Pic, GraphicFrame
readonly
The object this anchor hosts.
-
#to ⇒ Marker
readonly
A marker that returns the to cell anchor.
Instance Method Summary collapse
-
#add_chart(chart_type, options) ⇒ Chart
Creates a graphic frame and chart object associated with this anchor.
-
#add_pic(options = {}) ⇒ Object
Creates an image associated with this anchor.
-
#end_at(x, y = nil) ⇒ Object
sets the col, row attributes for the to marker objects is directly thru the object.
-
#index ⇒ Integer
The index of this anchor in the drawing.
-
#initialize(drawing, options = {}) ⇒ TwoCellAnchor
constructor
Creates a new TwoCellAnchor object c.start_at 5, 9.
-
#start_at(x, y = nil) ⇒ Object
sets the col, row attributes for the from marker.
-
#to_xml_string(str = +'')) ⇒ String
Serializes the object.
Methods included from OptionsParser
Constructor Details
#initialize(drawing, options = {}) ⇒ TwoCellAnchor
Creates a new TwoCellAnchor object c.start_at 5, 9
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 35 def initialize(drawing, = {}) @drawing = drawing drawing.anchors << self @from, @to = Marker.new, Marker.new(col: 5, row: 10) # bit of a hack to work around the fact that the coords for start at and end at # are passed in as an array when specified in initialization options - however start_at(*[:start_at]) if [:start_at] end_at(*[:end_at]) if [:end_at] end |
Instance Attribute Details
#drawing ⇒ Drawing (readonly)
The drawing that holds this anchor
28 29 30 |
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 28 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
12 13 14 |
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 12 def from @from end |
#object ⇒ Pic, GraphicFrame (readonly)
The object this anchor hosts
24 25 26 |
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 24 def object @object end |
#to ⇒ Marker (readonly)
A marker that returns the to cell anchor. The default to column and row are 5 and 10 respectively
15 16 17 |
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 15 def to @to end |
Instance Method Details
#add_chart(chart_type, options) ⇒ Chart
Creates a graphic frame and chart object associated with this anchor
65 66 67 68 |
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 65 def add_chart(chart_type, ) @object = GraphicFrame.new(self, chart_type, ) @object.chart end |
#add_pic(options = {}) ⇒ Object
Creates an image associated with this anchor.
71 72 73 |
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 71 def add_pic( = {}) @object = Pic.new(self, ) end |
#end_at(x, y = nil) ⇒ Object
the recommended way to set the to position for graphical
sets the col, row attributes for the to marker objects is directly thru the object
59 60 61 |
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 59 def end_at(x, y = nil) to.coord x, y end |
#index ⇒ Integer
The index of this anchor in the drawing
77 78 79 |
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 77 def index @drawing.anchors.index(self) end |
#start_at(x, y = nil) ⇒ Object
The recommended way to set the start position for graphical
sets the col, row attributes for the from marker. objects is directly thru the object.
51 52 53 |
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 51 def start_at(x, y = nil) from.coord x, y end |
#to_xml_string(str = +'')) ⇒ String
Serializes the object
84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 84 def to_xml_string(str = +'') str << '<xdr:twoCellAnchor>' str << '<xdr:from>' from.to_xml_string str str << '</xdr:from>' str << '<xdr:to>' to.to_xml_string str str << '</xdr:to>' object.to_xml_string(str) str << '<xdr:clientData/>' str << '</xdr:twoCellAnchor>' end |