lib/rdf/writer.rb in rdf-0.3.0.pre vs lib/rdf/writer.rb in rdf-0.3.0
- old
+ new
@@ -236,12 +236,12 @@
# @overload prefix(name)
# @param [Symbol, #to_s] name
#
# @return [RDF::URI]
def prefix(name, uri = nil)
- name = name.respond_to?(:to_sym) ? name.to_sym : name.to_s.to_sym
- uri.nil? ? prefixes[name] : prefixes[name] = RDF::URI(uri)
+ name = name.to_s.empty? ? nil : (name.respond_to?(:to_sym) ? name.to_sym : name.to_s.to_sym)
+ uri.nil? ? prefixes[name] : prefixes[name] = uri
end
alias_method :prefix!, :prefix
##
# Flushes the underlying output buffer.
@@ -298,21 +298,21 @@
write_triple(*statement.to_triple)
self
end
##
- # @param [Array<Array(RDF::Resource, RDF::URI, RDF::Value)>] triples
+ # @param [Array<Array(RDF::Resource, RDF::URI, RDF::Term)>] triples
# @return [void] `self`
def write_triples(*triples)
triples.each { |triple| write_triple(*triple) }
self
end
##
# @param [RDF::Resource] subject
# @param [RDF::URI] predicate
- # @param [RDF::Value] object
+ # @param [RDF::Term] object
# @return [void] `self`
# @raise [NotImplementedError] unless implemented in subclass
# @abstract
def write_triple(subject, predicate, object)
raise NotImplementedError.new("#{self.class}#write_triple") # override in subclasses
@@ -322,22 +322,24 @@
alias_method :insert_graph, :write_graph
alias_method :insert_statements, :write_statements
alias_method :insert_statement, :write_statement
##
- # @param [RDF::Value] value
+ # @param [RDF::Term] term
# @return [String]
- def format_value(value, options = {})
- case value
- when String then format_literal(RDF::Literal(value, options), options)
- when RDF::List then format_list(value, options)
- when RDF::Literal then format_literal(value, options)
- when RDF::URI then format_uri(value, options)
- when RDF::Node then format_node(value, options)
+ # @since 0.3.0
+ def format_term(term, options = {})
+ case term
+ when String then format_literal(RDF::Literal(term, options), options)
+ when RDF::List then format_list(term, options)
+ when RDF::Literal then format_literal(term, options)
+ when RDF::URI then format_uri(term, options)
+ when RDF::Node then format_node(term, options)
else nil
end
end
+ alias_method :format_value, :format_term # @deprecated
##
# @param [RDF::Node] value
# @param [Hash{Symbol => Object}] options
# @return [String]
@@ -372,10 +374,10 @@
# @param [Hash{Symbol => Object}] options
# @return [String]
# @abstract
# @since 0.2.3
def format_list(value, options = {})
- format_value(value.subject, options)
+ format_term(value.subject, options)
end
protected
##