Module: OoxmlParser::DocumentStyleHelper

Included in:
DocumentStructure, DocumentStyle
Defined in:
lib/ooxml_parser/docx_parser/document_structure/document_style/document_style_helper.rb

Overview

Helper methods for working with Style List

Instance Method Summary collapse

Instance Method Details

#based_on_styleDocumentStyle

Return document style which is based on

Returns:



28
29
30
# File 'lib/ooxml_parser/docx_parser/document_structure/document_style/document_style_helper.rb', line 28

def based_on_style
  document_style_by_id(@based_on)
end

#document_style_by_id(id) ⇒ DocumentStyle?

Return document style by its id

Parameters:

  • id (String)

    id of style

Returns:



19
20
21
22
23
24
# File 'lib/ooxml_parser/docx_parser/document_structure/document_style/document_style_helper.rb', line 19

def document_style_by_id(id)
  root_object.document_styles.each do |style|
    return style if style.style_id == id
  end
  nil
end

#document_style_by_name(name) ⇒ DocumentStyle?

Return document style by its name

Parameters:

  • name (String)

    name of style

Returns:



9
10
11
12
13
14
# File 'lib/ooxml_parser/docx_parser/document_structure/document_style/document_style_helper.rb', line 9

def document_style_by_name(name)
  root_object.document_styles.each do |style|
    return style if style.name == name
  end
  nil
end

#style_exist?(name) ⇒ True, False

Check if style exists in current document

Parameters:

  • name (String)

    name of style

Returns:

  • (True, False)


35
36
37
# File 'lib/ooxml_parser/docx_parser/document_structure/document_style/document_style_helper.rb', line 35

def style_exist?(name)
  !document_style_by_name(name).nil?
end