Class: Axlsx::Title
- Inherits:
-
Object
- Object
- Axlsx::Title
- Defined in:
- lib/axlsx/drawing/title.rb
Overview
A Title stores information about the title of a chart
Direct Known Subclasses
Instance Attribute Summary collapse
-
#cell ⇒ Cell
The cell that holds the text for the title.
-
#text ⇒ String
The text to be shown.
Instance Method Summary collapse
-
#initialize(title = "") ⇒ Title
constructor
Creates a new Title object.
-
#to_xml_string(str = '') ⇒ String
Serializes the object.
Constructor Details
#initialize(title = "") ⇒ Title
Creates a new Title object
16 17 18 19 |
# File 'lib/axlsx/drawing/title.rb', line 16 def initialize(title="") self.cell = title if title.is_a?(Cell) self.text = title.to_s unless title.is_a?(Cell) end |
Instance Attribute Details
#cell ⇒ Cell
The cell that holds the text for the title. Setting this property will automatically update the text attribute.
12 13 14 |
# File 'lib/axlsx/drawing/title.rb', line 12 def cell @cell end |
#text ⇒ String
The text to be shown. Setting this property directly with a string will remove the cell reference.
8 9 10 |
# File 'lib/axlsx/drawing/title.rb', line 8 def text @text end |
Instance Method Details
#to_xml_string(str = '') ⇒ String
Serializes the object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/axlsx/drawing/title.rb', line 45 def to_xml_string(str = '') str << '<c:title>' unless @text.empty? str << '<c:tx>' if @cell.is_a?(Cell) str << '<c:strRef>' str << '<c:f>' << Axlsx::cell_range([@cell]) << '</c:f>' str << '<c:strCache>' str << '<c:ptCount val="1"/>' str << '<c:pt idx="0">' str << '<c:v>' << @text << '</c:v>' str << '</c:pt>' str << '</c:strCache>' str << '</c:strRef>' else str << '<c:rich>' str << '<a:bodyPr/>' str << '<a:lstStyle/>' str << '<a:p>' str << '<a:r>' str << '<a:t>' << @text.to_s << '</a:t>' str << '</a:r>' str << '</a:p>' str << '</c:rich>' end str << '</c:tx>' end str << '<c:layout/>' str << '<c:overlay val="0"/>' str << '</c:title>' end |