Sha256: 563d9b7a6a1cef652c37b8884efb1c71d67462ce76f6d6240e12445f1a3328aa

Contents?: true

Size: 986 Bytes

Versions: 4

Compression:

Stored size: 986 Bytes

Contents

module OoxmlParser
  # Helper methods for working with Style List
  module DocumentStyleHelper
    # Return document style by its name
    # @param name [String] name of style
    # @return [DocumentStyle, nil]
    def document_style_by_name(name)
      root_object.document_styles.each do |style|
        return style if style.name == name
      end
      nil
    end

    # Return document style by its id
    # @param id [String] id of style
    # @return [DocumentStyle, nil]
    def document_style_by_id(id)
      root_object.document_styles.each do |style|
        return style if style.style_id == id
      end
      nil
    end

    # Return document style which is based on
    # @return [DocumentStyle]
    def based_on_style
      document_style_by_id(@based_on)
    end

    # Check if style exists in current document
    # @param name [String] name of style
    # @return [True, False]
    def style_exist?(name)
      !document_style_by_name(name).nil?
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ooxml_parser-0.4.1 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_style/document_style_helper.rb
ooxml_parser-0.4.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_style/document_style_helper.rb
ooxml_parser-0.3.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_style/document_style_helper.rb
ooxml_parser-0.2.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_style/document_style_helper.rb