Class: Axlsx::RichText
- Inherits:
-
SimpleTypedList
- Object
- Array
- 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
10 11 12 13 14 |
# File 'lib/axlsx/workbook/worksheet/rich_text.rb', line 10 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
17 18 19 |
# File 'lib/axlsx/workbook/worksheet/rich_text.rb', line 17 def cell @cell end |
Instance Method Details
#add_run(text, options = {}) ⇒ Object
Creates and adds a RichTextRun to this collectino
37 38 39 |
# File 'lib/axlsx/workbook/worksheet/rich_text.rb', line 37 def add_run(text, = {}) self << RichTextRun.new(text, ) end |
#autowidth ⇒ Number
Calculates the longest autowidth of the RichTextRuns in this collection
28 29 30 31 32 |
# File 'lib/axlsx/workbook/worksheet/rich_text.rb', line 28 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
43 44 45 |
# File 'lib/axlsx/workbook/worksheet/rich_text.rb', line 43 def runs self end |
#to_xml_string(str = +'')) ⇒ String
renders the RichTextRuns in this collection
50 51 52 53 |
# File 'lib/axlsx/workbook/worksheet/rich_text.rb', line 50 def to_xml_string(str = +'') each { |run| run.to_xml_string(str) } str end |