Class: Axlsx::Marker

Inherits:
Object
  • Object
show all
Includes:
OptionsParser
Defined in:
lib/axlsx/drawing/marker.rb

Overview

Note:

The recommended way to manage markers is Worksheet#add_chart Markers are created for a two cell anchor based on the :start and :end options.

The Marker class defines a point in the worksheet that drawing anchors attach to.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from OptionsParser

#parse_options

Constructor Details

#initialize(options = {}) ⇒ Marker

Creates a new Marker object

Options Hash (options):

  • col (Integer)
  • colOff (Integer)
  • row (Integer)
  • rowOff (Integer)


15
16
17
18
# File 'lib/axlsx/drawing/marker.rb', line 15

def initialize(options={})
  @col, @colOff, @row, @rowOff = 0, 0, 0, 0
  parse_options options
end

Instance Attribute Details

#colInteger

The column this marker anchors to



22
23
24
# File 'lib/axlsx/drawing/marker.rb', line 22

def col
  @col
end

#colOffInteger

The offset distance from this marker's column



26
27
28
# File 'lib/axlsx/drawing/marker.rb', line 26

def colOff
  @colOff
end

#rowInteger

The row this marker anchors to



30
31
32
# File 'lib/axlsx/drawing/marker.rb', line 30

def row
  @row
end

#rowOffInteger

The offset distance from this marker's row



34
35
36
# File 'lib/axlsx/drawing/marker.rb', line 34

def rowOff
  @rowOff
end

Instance Method Details

#coord(col, row = 0) ⇒ Object

shortcut to set the column, row position for this marker or an Array. String or Array.



50
51
52
53
54
# File 'lib/axlsx/drawing/marker.rb', line 50

def coord(col, row=0)
  coordinates = parse_coord_args(col, row)
  self.col = coordinates[0]
  self.row = coordinates[1]
end

#to_xml_string(str = '') ⇒ String

Serializes the object



59
60
61
62
63
# File 'lib/axlsx/drawing/marker.rb', line 59

def to_xml_string(str = '')
  [:col, :colOff, :row, :rowOff].each do |k|
    str << ('<xdr:' << k.to_s << '>' << self.send(k).to_s << '</xdr:' << k.to_s << '>')
  end
end