class Odf::Element::Abstract

Attributes

parent[R]
root[R]

Public Class Methods

new(parent, options = {}) click to toggle source
# File lib/odf/element/abstract.rb, line 6
def initialize(parent, options = {})
  @parent = parent
  @root   = document.content.xml.create_element(xml_tag, fetch_options(options))
  @parent.root.add_child(@root)
end

Public Instance Methods

document() click to toggle source
# File lib/odf/element/abstract.rb, line 21
def document
  parent.document
end
valid_options() click to toggle source

Accessor for valid options of element

# File lib/odf/element/abstract.rb, line 13
def valid_options
  @valid_options ||= defined?(self.class::VALID_OPTIONS) ? self.class::VALID_OPTIONS : {}
end
xml_tag() click to toggle source
# File lib/odf/element/abstract.rb, line 17
def xml_tag
  self.class::XML_TAG
end

Private Instance Methods

fetch_options(options) click to toggle source
# File lib/odf/element/abstract.rb, line 26
def fetch_options(options)
  options.reduce({}) do |ret, (k, v)|
    option = valid_options.fetch(k, k)
    ret.merge(option => v)
  end
end