Class: OpenXml::Docx::Style

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

Constant Summary collapse

VALID_STYLE_TYPES =
%i(character paragraph table)

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HasProperties

included

Constructor Details

#initialize(type) ⇒ Style

Returns a new instance of Style.



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

def initialize(type)
  self.type = type
end

Instance Attribute Details

#characterObject (readonly)

Returns the value of attribute character.



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

def character
  @character
end

#paragraphObject (readonly)

Returns the value of attribute paragraph.



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

def paragraph
  @paragraph
end

#tableObject (readonly)

Returns the value of attribute table.



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

def table
  @table
end

#typeObject

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#character_style?Boolean

Returns:

  • (Boolean)


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

def character_style?
  type == :character
end

#nameObject



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

def name
  "style"
end

#paragraph_style?Boolean

Returns:

  • (Boolean)


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

def paragraph_style?
  type == :paragraph
end

#table_style?Boolean

Returns:

  • (Boolean)


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

def table_style?
  type == :table
end

#tagObject



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

def tag
  :style
end

#to_xml(xml) ⇒ Object



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

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