Class RSS::Element
In: rss/rss.rb
Parent: Object

Methods

Included Modules

Utils

Constants

INDENT = " "
MUST_CALL_VALIDATORS = {}
MODEL = []
GET_ATTRIBUTES = []
HAVE_CHILDREN_ELEMENTS = []
NEED_INITIALIZE_VARIABLES = []
PLURAL_FORMS = {}

Attributes

do_validate  [RW] 

Public Class methods

[Source]

# File rss/rss.rb, line 387
      def get_attributes
        GET_ATTRIBUTES
      end

[Source]

# File rss/rss.rb, line 390
      def have_children_elements
        HAVE_CHILDREN_ELEMENTS
      end

[Source]

# File rss/rss.rb, line 501
      def indent_size
        @indent_size
      end

[Source]

# File rss/rss.rb, line 401
      def inherited(klass)
        klass.const_set("MUST_CALL_VALIDATORS", {})
        klass.const_set("MODEL", [])
        klass.const_set("GET_ATTRIBUTES", [])
        klass.const_set("HAVE_CHILDREN_ELEMENTS", [])
        klass.const_set("NEED_INITIALIZE_VARIABLES", [])
        klass.const_set("PLURAL_FORMS", {})

        klass.module_eval("public\n\n@tag_name = name.split(/::/).last\n@tag_name[0,1] = @tag_name[0,1].downcase\n@indent_size = name.split(/::/).size - 2\n@have_content = false\n\ndef self.must_call_validators\nsuper.merge(MUST_CALL_VALIDATORS)\nend\ndef self.model\nMODEL + super\nend\ndef self.get_attributes\nGET_ATTRIBUTES + super\nend\ndef self.have_children_elements\nHAVE_CHILDREN_ELEMENTS + super\nend\ndef self.need_initialize_variables\nNEED_INITIALIZE_VARIABLES + super\nend\ndef self.plural_forms\nsuper.merge(PLURAL_FORMS)\nend\n\n\ndef self.install_must_call_validator(prefix, uri)\nMUST_CALL_VALIDATORS[uri] = prefix\nend\n\ndef self.install_model(tag, occurs=nil)\nif m = MODEL.find {|t, o| t == tag}\nm[1] = occurs\nelse\nMODEL << [tag, occurs]\nend\nend\n\ndef self.install_get_attribute(name, uri, required=true)\nattr_writer name\nconvert_attr_reader name\nGET_ATTRIBUTES << [name, uri, required]\nend\n\ndef self.content_setup\nattr_writer :content\nconvert_attr_reader :content\ndef_content_only_to_s\n@have_content = true\nend\n\ndef self.have_content?\n@have_content\nend\n\ndef self.add_have_children_element(variable_name, plural_name)\nHAVE_CHILDREN_ELEMENTS << [variable_name, plural_name]\nend\n\ndef self.add_need_initialize_variable(variable_name)\nNEED_INITIALIZE_VARIABLES << variable_name\nend\n\ndef self.add_plural_form(singular, plural)\nPLURAL_FORMS[singular] = plural\nend\n\n")
      end

[Source]

# File rss/rss.rb, line 490
      def install_ns(prefix, uri)
        if self::NSPOOL.has_key?(prefix)
          raise OverlappedPrefixError.new(prefix)
        end
        self::NSPOOL[prefix] = uri
      end

[Source]

# File rss/rss.rb, line 384
      def model
        MODEL
      end

[Source]

# File rss/rss.rb, line 381
      def must_call_validators
        MUST_CALL_VALIDATORS
      end

[Source]

# File rss/rss.rb, line 393
      def need_initialize_variables
        NEED_INITIALIZE_VARIABLES
      end

[Source]

# File rss/rss.rb, line 509
    def initialize(do_validate=true)
      @converter = nil
      @do_validate = do_validate
      initialize_variables
    end

[Source]

# File rss/rss.rb, line 396
      def plural_forms
        PLURAL_FORMS
      end

[Source]

# File rss/rss.rb, line 482
      def required_prefix
        nil
      end

[Source]

# File rss/rss.rb, line 486
      def required_uri
        nil
      end

[Source]

# File rss/rss.rb, line 497
      def tag_name
        @tag_name
      end

Public Instance methods

[Source]

# File rss/rss.rb, line 538
    def convert(value)
      if @converter
        @converter.convert(value)
      else
        value
      end
    end

[Source]

# File rss/rss.rb, line 527
    def converter=(converter)
      @converter = converter
      targets = children.dup
      self.class.have_children_elements.each do |variable_name, plural_name|
        targets.concat(__send__(plural_name))
      end
      targets.each do |target|
        target.converter = converter unless target.nil?
      end
    end

[Source]

# File rss/rss.rb, line 519
    def full_name
      tag_name
    end

[Source]

# File rss/rss.rb, line 523
    def indent_size
      self.class.indent_size
    end

[Source]

# File rss/rss.rb, line 556
    def setup_maker(maker)
      target = maker_target(maker)
      unless target.nil?
        setup_maker_attributes(target)
        setup_maker_element(target)
        setup_maker_elements(target)
      end
    end

[Source]

# File rss/rss.rb, line 515
    def tag_name
      self.class.tag_name
    end

[Source]

# File rss/rss.rb, line 546
    def validate
      validate_attribute
      __validate
    end

[Source]

# File rss/rss.rb, line 551
    def validate_for_stream(tags)
      validate_attribute
      __validate(tags, false)
    end

[Validate]