diff options
| author | Randy Morgan <[email protected]> | 2012-04-01 00:35:26 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2012-04-01 00:35:26 +0900 |
| commit | 22a341841f191a5aa00e87b1f166b4f25cc67f0a (patch) | |
| tree | 505f46708d5cac7d33d0dd6679c125e2eb819075 /lib/axlsx/drawing/title.rb | |
| parent | bb2117ba17297e02a0fc6d5ad5a22462e72a9a79 (diff) | |
| download | caxlsx-22a341841f191a5aa00e87b1f166b4f25cc67f0a.tar.gz caxlsx-22a341841f191a5aa00e87b1f166b4f25cc67f0a.zip | |
part way through changing all serialization to use string concatenation prior to dropping Nokogiri dep in production.
Diffstat (limited to 'lib/axlsx/drawing/title.rb')
| -rw-r--r-- | lib/axlsx/drawing/title.rb | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/lib/axlsx/drawing/title.rb b/lib/axlsx/drawing/title.rb index cc382205..a7b8e715 100644 --- a/lib/axlsx/drawing/title.rb +++ b/lib/axlsx/drawing/title.rb @@ -2,7 +2,7 @@ module Axlsx # A Title stores information about the title of a chart class Title - + # The text to be shown. Setting this property directly with a string will remove the cell reference. # @return [String] attr_reader :text @@ -17,9 +17,9 @@ module Axlsx self.cell = title if title.is_a?(Cell) self.text = title.to_s unless title.is_a?(Cell) end - + # @see text - def text=(v) + def text=(v) DataTypeValidator.validate 'Title.text', String, v @text = v @cell = nil @@ -30,7 +30,7 @@ module Axlsx def cell=(v) DataTypeValidator.validate 'Title.text', Cell, v @cell = v - @text = v.value.to_s + @text = v.value.to_s v end @@ -38,7 +38,25 @@ module Axlsx #def layout=(v) DataTypeValidator.validate 'Title.layout', Layout, v; @layout = v; end #def overlay=(v) Axlsx::validate_boolean v; @overlay=v; end #def spPr=(v) DataTypeValidator.validate 'Title.spPr', SpPr, v; @spPr = v; end - + + def to_xml_string(str = '') + str << '<c:title>' + unless @text.empty? + str << '<c:tx>' + 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>' + str << '</c:tx>' + end + str << '</c:title>' + end + # Serializes the chart title # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to. # @return [String] @@ -59,8 +77,8 @@ module Axlsx end xml[:c].layout xml[:c].overlay :val=>0 - } + } end - + end end |
