class RubyDocx::Elements::TableStyle

Public Instance Methods

align() click to toggle source
# File lib/ruby_docx/elements/table_style.rb, line 22
def align
  ele = @node.xpath(".//w:jc").last

  if ele
    v = ele.attributes["val"].value.to_s
    if v == "start"
      "left"
    elsif v == "end"
      "right"
    elsif v == "center"
      "center"
    end
  else
    nil
  end
end
bold?() click to toggle source
# File lib/ruby_docx/elements/table_style.rb, line 39
def bold?
  false
end
color() click to toggle source
# File lib/ruby_docx/elements/table_style.rb, line 63
def color
  ele = @node.xpath(".//w:color").last

  if ele
    v = ele.attributes["val"].value
    if v.to_s == "auto"
      nil
    else
      v
    end
  else
    nil
  end
end
font_name() click to toggle source
# File lib/ruby_docx/elements/table_style.rb, line 78
def font_name
  ele = @node.xpath(".//w:rFonts").last

  if ele
    ascii = ele.attributes["ascii"]
    cs = ele.attributes["cs"]
    hAnsi = ele.attributes["hAnsi"]

    ascii.value
  else
    nil
  end
end
font_size() click to toggle source
# File lib/ruby_docx/elements/table_style.rb, line 43
def font_size
  ele = @node.xpath(".//w:sz").last

  if ele
    v = ele.attributes["val"].value
    v.to_i/2
  else
    nil
  end

end
fonts() click to toggle source
# File lib/ruby_docx/elements/table_style.rb, line 93
def fonts
  ele = @node.xpath(".//w:rFonts").last

  if ele
    ascii = ele.attributes["ascii"]
    cs = ele.attributes["cs"]
    hAnsi = ele.attributes["hAnsi"]

    [ascii.value, cs.value, hAnsi.value].uniq
  else
    nil
  end
end
height() click to toggle source
# File lib/ruby_docx/elements/table_style.rb, line 59
def height
  nil
end
to_s() click to toggle source

attr_reader :font_name, :font_size, :color, :text_align, :fonts

# File lib/ruby_docx/elements/table_style.rb, line 5
def to_s
  arry = []
  if font_size
    arry << "font-size: #{font_size}pt"
  end

  if fonts
    arry << "font-family: #{fonts.join(",")}"
  end

  if color
    arry << "color: #{color}"
  end

  arry.join(";")
end
width() click to toggle source
# File lib/ruby_docx/elements/table_style.rb, line 55
def width
  nil
end