Class: Axlsx::RichText

Inherits:
SimpleTypedList
  • Object
show all
Defined in:
lib/axlsx/workbook/worksheet/rich_text.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text = nil, options = {}) {|_self| ... } ⇒ RichText

Returns a new instance of RichText.

Yields:

  • (_self)

Yield Parameters:



3
4
5
6
7
# File 'lib/axlsx/workbook/worksheet/rich_text.rb', line 3

def initialize(text = nil, options={})
  super(RichTextRun)
  add_run(text, options) unless text.nil?
  yield self if block_given?
end

Instance Attribute Details

#cellObject

Returns the value of attribute cell.



9
10
11
# File 'lib/axlsx/workbook/worksheet/rich_text.rb', line 9

def cell
  @cell
end

Instance Method Details

#add_run(text, options = {}) ⇒ Object



22
23
24
# File 'lib/axlsx/workbook/worksheet/rich_text.rb', line 22

def add_run(text, options={})
  self << RichTextRun.new(text, options)
end

#autowidthObject



16
17
18
19
20
# File 'lib/axlsx/workbook/worksheet/rich_text.rb', line 16

def autowidth
  widtharray = [0] # Are arrays the best way of solving this problem?
  each { |run| run.autowidth(widtharray) }
  widtharray.max
end

#runsObject



26
27
28
# File 'lib/axlsx/workbook/worksheet/rich_text.rb', line 26

def runs
  self
end

#to_xml_string(str = '') ⇒ Object



30
31
32
33
# File 'lib/axlsx/workbook/worksheet/rich_text.rb', line 30

def to_xml_string(str='')
  each{ |run| run.to_xml_string(str) }
  str
end