class OpenXml::Docx::Properties::BaseProperty

Attributes

allowed_tags[R]
property_name[R]
value[R]

Public Class Methods

name(*args) click to toggle source
# File lib/openxml/docx/properties/base_property.rb, line 21
def name(*args)
  @property_name = args.first if args.any?
  @name
end
namespace(*args) click to toggle source
# File lib/openxml/docx/properties/base_property.rb, line 26
def namespace(*args)
  @namespace = args.first if args.any?
  @namespace
end
new(tag=nil, *args) click to toggle source
# File lib/openxml/docx/properties/base_property.rb, line 32
def initialize(tag=nil, *args)
  return unless self.class.allowed_tags
  unless self.class.allowed_tags.include?(tag)
    raise ArgumentError, "Invalid tag name for #{name}: #{tag.inspect}. It should be one of #{self.class.allowed_tags.join(", ")}."
  end
  @tag = tag
end
tag(*args) click to toggle source
# File lib/openxml/docx/properties/base_property.rb, line 16
def tag(*args)
  @tag = args.first if args.any?
  @tag
end
tag_is_one_of(tags) click to toggle source
# File lib/openxml/docx/properties/base_property.rb, line 11
def tag_is_one_of(tags)
  attr_accessor :tag
  @allowed_tags = tags
end

Public Instance Methods

default_name() click to toggle source
# File lib/openxml/docx/properties/base_property.rb, line 48
def default_name
  class_name.gsub(/(.)([A-Z])/, '\1_\2').downcase
end
default_namespace() click to toggle source
# File lib/openxml/docx/properties/base_property.rb, line 64
def default_namespace
  :w
end
default_tag() click to toggle source
# File lib/openxml/docx/properties/base_property.rb, line 56
def default_tag
  (class_name[0, 1].downcase + class_name[1..-1]).to_sym
end
name() click to toggle source
# File lib/openxml/docx/properties/base_property.rb, line 44
def name
  self.class.property_name || default_name
end
namespace() click to toggle source
# File lib/openxml/docx/properties/base_property.rb, line 60
def namespace
  self.class.namespace || default_namespace
end
render?() click to toggle source
# File lib/openxml/docx/properties/base_property.rb, line 40
def render?
  !value.nil?
end
tag() click to toggle source
# File lib/openxml/docx/properties/base_property.rb, line 52
def tag
  self.class.tag || default_tag
end

Private Instance Methods

class_name() click to toggle source
# File lib/openxml/docx/properties/base_property.rb, line 70
def class_name
  self.class.to_s.split(/::/).last
end