class Axlsx::RichText

A simple, self serializing class for storing TextRuns

Attributes

cell[R]

The cell that owns this RichText collection

Public Class Methods

new(text = nil, options={}) { |self| ... } click to toggle source

creates a new RichText collection @param [String] text -optional The text to use in creating the first RichTextRun @param [Object] options -optional The options to use in creating the first RichTextRun @yield [RichText] self

Calls superclass method Axlsx::SimpleTypedList::new
# File lib/axlsx/workbook/worksheet/rich_text.rb, line 10
def initialize(text = nil, options={})
  super(RichTextRun)
  add_run(text, options) unless text.nil?
  yield self if block_given?
end

Public Instance Methods

add_run(text, options={}) click to toggle source

Creates and adds a RichTextRun to this collectino @param [String] text The text to use in creating a new RichTextRun @param [Object] options The options to use in creating the new RichTextRun

# File lib/axlsx/workbook/worksheet/rich_text.rb, line 37
def add_run(text, options={})
  self << RichTextRun.new(text, options)
end
autowidth() click to toggle source

Calculates the longest autowidth of the RichTextRuns in this collection @return [Number]

# 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
cell=(cell) click to toggle source

Assign the cell for this RichText collection @param [Cell] cell The cell which all RichTextRuns in the collection will belong to

# File lib/axlsx/workbook/worksheet/rich_text.rb, line 21
def cell=(cell)
  @cell = cell
  each { |run| run.cell = cell }
end
runs() click to toggle source

The RichTextRuns we own @return [RichText]

# File lib/axlsx/workbook/worksheet/rich_text.rb, line 43
def runs
  self
end
to_xml_string(str='') click to toggle source

renders the RichTextRuns in this collection @param [String] str @return [String]

# File lib/axlsx/workbook/worksheet/rich_text.rb, line 50
def to_xml_string(str='')
  each{ |run| run.to_xml_string(str) }
  str
end