class RubyDocx::Elements::TextRun

Attributes

color[R]
content[RW]
font_name[R]
font_size[R]

Public Instance Methods

to_html() click to toggle source
# File lib/ruby_docx/elements/text_run.rb, line 25
def to_html
  if underline?
    s = "<span>"

    self.elements.map do |ele|
      if ele.class == RubyDocx::Elements::Text
        s += ele.to_s.gsub(/ /, "_")
      else
        s += ele.to_html
      end
    end

    s += "</span>"

    s
  else
    "<span>#{self.elements.map(&:to_html).join}</span>"
  end
end
to_s() click to toggle source
# File lib/ruby_docx/elements/text_run.rb, line 10
def to_s
  if underline?
    self.elements.map do |ele|
      if ele.class == RubyDocx::Elements::Text
        ele.to_s.gsub(/ /, "_")
      else
        ele.to_s
      end
    end.join(" ")

  else
    self.elements.map(&:to_s).join(" ")
  end
end
underline?() click to toggle source
# File lib/ruby_docx/elements/text_run.rb, line 6
def underline?
  @node.xpath(".//w:u").size > 0
end