Sha256: 2a21e9bb976c520ee4c7943f552558040e8f4bf805b8ce699fa24284a913132e

Contents?: true

Size: 667 Bytes

Versions: 4

Compression:

Stored size: 667 Bytes

Contents

module RDF::N3::Algebra::Str
  # The subject is a list, whose first member is a format string, and whose remaining members are arguments to the format string. The formating string is in the style of python's % operator, very similar to C's sprintf(). The object is calculated from the subject.
  class Format < RDF::N3::Algebra::ListOperator
    include RDF::N3::Algebra::Builtin
    NAME = :strFormat
    URI = RDF::N3::Str.format

    ##
    # @param [RDF::N3::List] list
    # @return [RDF::Term]
    # @see RDF::N3::ListOperator#evaluate
    def resolve(list)
      format, *args = list.to_a.map(&:value)
      str = RDF::Literal(format % args)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rdf-n3-3.3.0 lib/rdf/n3/algebra/str/format.rb
rdf-n3-3.2.1 lib/rdf/n3/algebra/str/format.rb
rdf-n3-3.2.0 lib/rdf/n3/algebra/str/format.rb
rdf-n3-3.1.2 lib/rdf/n3/algebra/str/format.rb