Sha256: 04d19aafe0f034a3fbadd0d1f06a3639f390d94a710e6e0e9feba70ed9420e0b

Contents?: true

Size: 1.49 KB

Versions: 12

Compression:

Stored size: 1.49 KB

Contents

#   Copyright 2011 innoQ Deutschland GmbH
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.

module IqRdf
  class Predicate < Uri

    attr_reader :subject

    def initialize(namespace, uri_postfix, subject, lang = nil)
      super(namespace, uri_postfix, nil, lang)
      @subject = subject
    end

    def build_xml(xml)
      raise "XML Output won't work with full URIs as predicates yet" unless namespace.token # There is a dummy_empty_namespace without token => postfix is a full uri!
      nodes.each do |node|
        node.build_xml(xml) do |*args|
          block = args.pop if args.last.is_a?(Proc)
          params = namespace.token == :default ? [self.uri_postfix.to_s] : [namespace.token.to_s, self.uri_postfix.to_sym]
          params += args
          params << {"xml:lang" => xml_lang} if xml_lang
          if block
            xml.tag!(*params) do
              block.call
            end
          else
            xml.tag!(*params)
          end
        end
      end
    end

  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
iq_rdf-0.1.13 lib/iq_rdf/predicate.rb
iq_rdf-0.1.12 lib/iq_rdf/predicate.rb
iq_rdf-0.1.10 lib/iq_rdf/predicate.rb
iq_rdf-0.1.8 lib/iq_rdf/predicate.rb
iq_rdf-0.1.7 lib/iq_rdf/predicate.rb
iq_rdf-0.1.6 lib/iq_rdf/predicate.rb
iq_rdf-0.1.5 lib/iq_rdf/predicate.rb
iq_rdf-0.1.4 lib/iq_rdf/predicate.rb
iq_rdf-0.1.3 lib/iq_rdf/predicate.rb
iq_rdf-0.1.2 lib/iq_rdf/predicate.rb
iq_rdf-0.1.0 lib/iq_rdf/predicate.rb
iq_rdf-0.0.15 lib/iq_rdf/predicate.rb