Sha256: d1607bcb962818443d2cd44dbb4042b2cb1438c8a2a7a64e2ef26736b11be75a

Contents?: true

Size: 1.09 KB

Versions: 48

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

module OoxmlParser
  # Class for storing `w:tab`, `a:tab` data
  class Tab < OOXMLDocumentObject
    # @return [Symbol] Specifies the style of the tab.
    attr_accessor :value
    # @return [Symbol] Specifies the leader symbol of tab
    attr_reader :leader
    # @return [OOxmlSize] Specifies the position of the tab stop.
    attr_accessor :position

    alias align value

    # Parse ParagraphTab object
    # @param node [Nokogiri::XML:Element] node to parse
    # @return [ParagraphTab] result of parsing
    def parse(node)
      node.attributes.each do |key, value|
        case key
        when 'algn', 'val'
          @value = value_to_symbol(value)
        when 'leader'
          @leader = value_to_symbol(value)
        when 'pos'
          @position = OoxmlSize.new(value.value.to_f, position_unit(node))
        end
      end
      self
    end

    private

    # @param node [Nokogiri::XML:Element] node to determine size
    # @return [Symbol] type of size unit
    def position_unit(node)
      return :emu if node.namespace.prefix == 'a'

      :dxa
    end
  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
ooxml_parser-0.8.1 lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs/tab.rb
ooxml_parser-0.8.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs/tab.rb
ooxml_parser-0.7.2 lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs/tab.rb
ooxml_parser-0.7.1 lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs/tab.rb
ooxml_parser-0.7.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs/tab.rb
ooxml_parser-0.6.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs/tab.rb
ooxml_parser-0.5.1 lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs/tab.rb
ooxml_parser-0.5.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs/tab.rb