class Sablon::DOM::ContentTypes
Adds new content types to the document
Public Class Methods
extend_model(model_klass)
click to toggle source
extends the Model
class so it now has an “add_content_type” method
Calls superclass method
# File lib/sablon/document_object_model/content_types.rb, line 9 def self.extend_model(model_klass) super do define_method(:add_content_type) do |extension, type| @dom['[Content_Types].xml'].add_content_type(extension, type) end end end
new(xml_node)
click to toggle source
Sets up the class instance to handle new relationships for a document. I only care about tags that have an integer component
Calls superclass method
# File lib/sablon/document_object_model/content_types.rb, line 19 def initialize(xml_node) super # @types = xml_node.root end
Public Instance Methods
add_content_type(extension, type)
click to toggle source
Adds a new content type to the file
# File lib/sablon/document_object_model/content_types.rb, line 26 def add_content_type(extension, type) # # don't add duplicate extensions to the document return unless @types.css(%(Default[Extension="#{extension}"])).empty? # @types << %(<Default Extension="#{extension}" ContentType="#{type}"/>) end