Sha256: 3349c43bc93db5614d87a5b0d354518f1f9044a44291ed034681baea80c23e88
Contents?: true
Size: 1.55 KB
Versions: 13
Compression:
Stored size: 1.55 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 Collection attr_reader :elements def initialize(collection) @elements = [] collection.each do |element| element = Literal.new(element) unless element.is_a?(IqRdf::Uri) || element.is_a?(IqRdf::Literal) @elements << element end end def to_s(lang = nil) "(#{@elements.map{|e| e.to_s(lang)}.join(" ")})" end def build_xml(xml, elements = nil, &block) elements ||= @elements.dup block.call({}, lambda { xml.rdf :List do elements.shift.build_xml(xml) do |*args| xml.rdf(:first, *args) end if elements.size > 0 build_xml(xml, elements) do |opts, block| xml.rdf :rest do block.call end end else xml.rdf :rest, "rdf:resource" => Rdf.nil.full_uri end end } ) end end end
Version data entries
13 entries across 13 versions & 1 rubygems