Sha256: 2fb302444d9c7e3666be870efc20690d6b4bdcbf7fd4a6727c955b0b8323b1e3

Contents?: true

Size: 1.2 KB

Versions: 40

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

module OoxmlParser
  # Parsing `fonts` tag
  class Font < OOXMLDocumentObject
    attr_accessor :name, :size, :font_style, :color
    # @return [ValuedChild] vertical alignment of font
    attr_reader :vertical_alignment

    def initialize(parent: nil)
      @name = 'Calibri'
      @size = 11
      super
    end

    # Parse Font object
    # @param node [Nokogiri::XML:Element] node to parse
    # @return [Font] result of parsing
    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
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
ooxml_parser-0.37.1 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fonts/font.rb
ooxml_parser-0.37.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fonts/font.rb
ooxml_parser-0.36.1 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fonts/font.rb
ooxml_parser-0.36.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fonts/font.rb
ooxml_parser-0.35.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fonts/font.rb
ooxml_parser-0.34.2 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fonts/font.rb
ooxml_parser-0.34.1 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fonts/font.rb
ooxml_parser-0.34.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fonts/font.rb
ooxml_parser-0.33.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fonts/font.rb
ooxml_parser-0.32.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fonts/font.rb
ooxml_parser-0.31.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fonts/font.rb
ooxml_parser-0.30.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fonts/font.rb
ooxml_parser-0.29.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fonts/font.rb
ooxml_parser-0.28.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fonts/font.rb
ooxml_parser-0.27.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fonts/font.rb
ooxml_parser-0.26.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fonts/font.rb
ooxml_parser-0.25.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fonts/font.rb
ooxml_parser-0.24.0 lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fonts/font.rb
ooxml_parser-0.23.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fonts/font.rb
ooxml_parser-0.22.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fonts/font.rb