Class: OpenXml::Docx::Style

Inherits:
Object
  • Object
show all
Includes:
AttributeBuilder, PropertyBuilder
Defined in:
lib/openxml/docx/style.rb

Constant Summary collapse

VALID_STYLE_TYPES =
%i(character paragraph table)

Constants included from AttributeBuilder

AttributeBuilder::VALID_THEME_COLORS, AttributeBuilder::VALID_TYPES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PropertyBuilder

included

Methods included from AttributeBuilder

#attributes, included, #render?

Constructor Details

#initialize(type) ⇒ Style

Returns a new instance of Style.



29
30
31
# File 'lib/openxml/docx/style.rb', line 29

def initialize(type)
  self.type = type
end

Instance Attribute Details

#characterObject (readonly)

Returns the value of attribute character.



7
8
9
# File 'lib/openxml/docx/style.rb', line 7

def character
  @character
end

#paragraphObject (readonly)

Returns the value of attribute paragraph.



7
8
9
# File 'lib/openxml/docx/style.rb', line 7

def paragraph
  @paragraph
end

#tableObject (readonly)

Returns the value of attribute table.



7
8
9
# File 'lib/openxml/docx/style.rb', line 7

def table
  @table
end

#typeObject

Returns the value of attribute type.



7
8
9
# File 'lib/openxml/docx/style.rb', line 7

def type
  @type
end

Instance Method Details

#character_style?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/openxml/docx/style.rb', line 56

def character_style?
  type == :character
end

#nameObject



42
43
44
# File 'lib/openxml/docx/style.rb', line 42

def name
  "style"
end

#paragraph_style?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/openxml/docx/style.rb', line 52

def paragraph_style?
  type == :paragraph
end

#table_style?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/openxml/docx/style.rb', line 60

def table_style?
  type == :table
end

#tagObject



38
39
40
# File 'lib/openxml/docx/style.rb', line 38

def tag
  :style
end

#to_xml(xml) ⇒ Object



46
47
48
49
50
# File 'lib/openxml/docx/style.rb', line 46

def to_xml(xml)
  xml["w"].public_send(tag, xml_attributes) {
    property_xml(xml)
  }
end