Sha256: 177e93c4b745f7cbc0ca513a3b25dd217bb259a598eb9c5056762130a60aef2b

Contents?: true

Size: 913 Bytes

Versions: 2

Compression:

Stored size: 913 Bytes

Contents

module OpenXml
  module Docx
    module Properties
      class BaseProperty
        attr_reader :value

        class << self
          attr_reader :property_name

          def tag(*args)
            @tag = args.first if args.any?
            @tag
          end

          def name(*args)
            @property_name = args.first if args.any?
            @name
          end
        end

        def render?
          !value.nil?
        end

        def name
          self.class.property_name || default_name
        end

        def default_name
          class_name.gsub(/(.)([A-Z])/, '\1_\2').downcase
        end

        def tag
          self.class.tag || default_tag
        end

        def default_tag
          (class_name[0, 1].downcase + class_name[1..-1]).to_sym
        end

      private

        def class_name
          self.class.to_s.split(/::/).last
        end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
openxml-docx-0.8.0 lib/openxml/docx/properties/base_property.rb
openxml-docx-0.8.0.beta1 lib/openxml/docx/properties/base_property.rb