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.37.1 lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/tabs/tab.rb
ooxml_parser-0.37.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/tabs/tab.rb
ooxml_parser-0.36.1 lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/tabs/tab.rb
ooxml_parser-0.36.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/tabs/tab.rb
ooxml_parser-0.35.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/tabs/tab.rb
ooxml_parser-0.34.2 lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/tabs/tab.rb
ooxml_parser-0.34.1 lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/tabs/tab.rb
ooxml_parser-0.34.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/tabs/tab.rb
ooxml_parser-0.33.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/tabs/tab.rb
ooxml_parser-0.32.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/tabs/tab.rb
ooxml_parser-0.31.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs/tab.rb
ooxml_parser-0.30.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs/tab.rb
ooxml_parser-0.29.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs/tab.rb
ooxml_parser-0.28.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs/tab.rb
ooxml_parser-0.27.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs/tab.rb
ooxml_parser-0.26.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs/tab.rb
ooxml_parser-0.25.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs/tab.rb
ooxml_parser-0.24.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs/tab.rb
ooxml_parser-0.23.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs/tab.rb
ooxml_parser-0.22.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs/tab.rb