class OoxmlParser::Font

Parsing ‘fonts` tag

Attributes

color[RW]
font_style[RW]
name[RW]
size[RW]
vertical_alignment[R]

@return [ValuedChild] vertical alignment of font

Public Class Methods

new(parent: nil) click to toggle source
Calls superclass method OoxmlParser::OOXMLDocumentObject::new
# File lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fonts/font.rb, line 10
def initialize(parent: nil)
  @name = 'Calibri'
  @size = 11
  super
end

Public Instance Methods

parse(node) click to toggle source

Parse Font object @param node [Nokogiri::XML:Element] node to parse @return [Font] result of parsing

# File lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fonts/font.rb, line 19
def parse(node)
  @font_style = FontStyle.new
  node.xpath('*').each do |node_child|
    case node_child.name
    when 'name'
      @name = node_child.attribute('val').value
    when 'sz'
      @size = node_child.attribute('val').value.to_f
    when 'b'
      @font_style.bold = true
    when 'i'
      @font_style.italic = true
    when 'strike'
      @font_style.strike = :single
    when 'u'
      @font_style.underlined = Underline.new(:single)
    when 'color'
      @color = OoxmlColor.new(parent: self).parse(node_child)
    when 'vertAlign'
      @vertical_alignment = ValuedChild.new(:symbol, parent: self).parse(node_child)
    end
  end
  self
end