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

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

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

Returns:

  • (Integer)


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

def col
  @col
end

#colOffInteger

The offset distance from this marker's column

Returns:

  • (Integer)


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

def colOff
  @colOff
end

#rowInteger

The row this marker anchors to

Returns:

  • (Integer)


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

def row
  @row
end

#rowOffInteger

The offset distance from this marker's row

Returns:

  • (Integer)


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.

Parameters:

  • col

    the column for the marker, a Cell object or a string reference like "B7"

  • row (defaults to: 0)

    the row of the marker. This is ignored if the col parameter is a Cell or



65
66
67
68
69
# File 'lib/axlsx/drawing/marker.rb', line 65

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

Parameters:

  • str (String) (defaults to: +''))

Returns:

  • (String)


74
75
76
77
78
# File 'lib/axlsx/drawing/marker.rb', line 74

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