Class: Axlsx::RichText
- Inherits:
-
SimpleTypedList
- Object
- SimpleTypedList
- Axlsx::RichText
- Defined in:
- lib/axlsx/workbook/worksheet/rich_text.rb
Overview
A simple, self serializing class for storing TextRuns
Instance Attribute Summary collapse
-
#cell ⇒ Object
The cell that owns this RichText collection.
Instance Method Summary collapse
-
#add_run(text, options = {}) ⇒ Object
Creates and adds a RichTextRun to this collectino.
-
#autowidth ⇒ Number
Calculates the longest autowidth of the RichTextRuns in this collection.
-
#initialize(text = nil, options = {}) {|RichText| ... } ⇒ RichText
constructor
creates a new RichText collection.
-
#runs ⇒ RichText
The RichTextRuns we own.
-
#to_xml_string(str = '') ⇒ String
renders the RichTextRuns in this collection.
Constructor Details
#initialize(text = nil, options = {}) {|RichText| ... } ⇒ RichText
creates a new RichText collection
8 9 10 11 12 |
# File 'lib/axlsx/workbook/worksheet/rich_text.rb', line 8 def initialize(text = nil, = {}) super(RichTextRun) add_run(text, ) unless text.nil? yield self if block_given? end |
Instance Attribute Details
#cell ⇒ Object
The cell that owns this RichText collection
15 16 17 |
# File 'lib/axlsx/workbook/worksheet/rich_text.rb', line 15 def cell @cell end |
Instance Method Details
#add_run(text, options = {}) ⇒ Object
Creates and adds a RichTextRun to this collectino
35 36 37 |
# File 'lib/axlsx/workbook/worksheet/rich_text.rb', line 35 def add_run(text, = {}) self << RichTextRun.new(text, ) end |
#autowidth ⇒ Number
Calculates the longest autowidth of the RichTextRuns in this collection
26 27 28 29 30 |
# File 'lib/axlsx/workbook/worksheet/rich_text.rb', line 26 def autowidth widtharray = [0] # Are arrays the best way of solving this problem? each { |run| run.autowidth(widtharray) } widtharray.max end |
#runs ⇒ RichText
The RichTextRuns we own
41 42 43 |
# File 'lib/axlsx/workbook/worksheet/rich_text.rb', line 41 def runs self end |
#to_xml_string(str = '') ⇒ String
renders the RichTextRuns in this collection
48 49 50 51 |
# File 'lib/axlsx/workbook/worksheet/rich_text.rb', line 48 def to_xml_string(str = '') each { |run| run.to_xml_string(str) } str end |