class OpenXml::Docx::Style
Constants
- VALID_STYLE_TYPES
Attributes
character[R]
paragraph[R]
table[R]
type[R]
Public Class Methods
new(type)
click to toggle source
# File lib/openxml/docx/style.rb, line 30 def initialize(type) self.type = type end
Public Instance Methods
character_style?()
click to toggle source
# File lib/openxml/docx/style.rb, line 57 def character_style? type == :character end
name()
click to toggle source
# File lib/openxml/docx/style.rb, line 43 def name "style" end
paragraph_style?()
click to toggle source
# File lib/openxml/docx/style.rb, line 53 def paragraph_style? type == :paragraph end
table_style?()
click to toggle source
# File lib/openxml/docx/style.rb, line 61 def table_style? type == :table end
tag()
click to toggle source
# File lib/openxml/docx/style.rb, line 39 def tag :style end
to_xml(xml)
click to toggle source
# File lib/openxml/docx/style.rb, line 47 def to_xml(xml) xml["w"].public_send(tag, xml_attributes) { property_xml(xml) } end
type=(value)
click to toggle source
# File lib/openxml/docx/style.rb, line 34 def type=(value) @type = value send "install_#{value}_properties" end
Private Instance Methods
install_character_properties()
click to toggle source
# File lib/openxml/docx/style.rb, line 75 def install_character_properties @paragraph = nil @table = nil @character = OpenXml::Docx::Elements::Run.new end
install_paragraph_properties()
click to toggle source
# File lib/openxml/docx/style.rb, line 69 def install_paragraph_properties @table = nil @character = OpenXml::Docx::Elements::Run.new @paragraph = OpenXml::Docx::Elements::Paragraph.new end
install_table_properties()
click to toggle source
# File lib/openxml/docx/style.rb, line 81 def install_table_properties @character = nil @paragraph = nil @table = OpenXml::Docx::Elements::Table.new end
property_xml(xml)
click to toggle source
# File lib/openxml/docx/style.rb, line 87 def property_xml(xml) style_property_xml(xml) return table.property_xml(xml) if table_style? character.property_xml(xml) paragraph.property_xml(xml) if paragraph_style? end
style_property_xml(xml)
click to toggle source
# File lib/openxml/docx/style.rb, line 95 def style_property_xml(xml) props = properties.keys.map(&method(:send)).compact return if props.none?(&:render?) props.each { |prop| prop.to_xml(xml) } end
valid_style_type(value)
click to toggle source
# File lib/openxml/docx/style.rb, line 101 def valid_style_type(value) valid_in? value, VALID_STYLE_TYPES end