class SPARQL::Algebra::Operator::Lang

The SPARQL `lang` operator.

@see www.w3.org/TR/sparql11-query/#func-lang

Constants

NAME

Public Instance Methods

apply(literal, **options) click to toggle source

Returns the language tag of the operand, if it has one.

If the operand has no language tag, returns `“”`.

@param [RDF::Literal] literal

a literal

@return [RDF::Literal] a simple literal @raise [TypeError] if the operand is not a literal

# File lib/sparql/algebra/operator/lang.rb, line 21
def apply(literal, **options)
  case literal
    when RDF::Literal then RDF::Literal(literal.language.to_s)
    else raise TypeError, "expected an RDF::Literal, but got #{literal.inspect}"
  end
end