Sha256: 8945f43a8394f42531a20c4c5952d7fb1741766aaffbcf65a21c4eccf827dbe9

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

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

3 entries across 3 versions & 1 rubygems

Version Path
ooxml_parser-0.4.1 lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs/tab.rb
ooxml_parser-0.4.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs/tab.rb
ooxml_parser-0.3.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs/tab.rb