Class: SPARQL::Algebra::Operator::Lang

Inherits:
Unary show all
Includes:
Evaluatable
Defined in:
lib/sparql/algebra/operator/lang.rb

Overview

The SPARQL lang operator.

Constant Summary collapse

NAME =
:lang

Constants inherited from Unary

Unary::ARITY

Constants inherited from SPARQL::Algebra::Operator

ARITY

Instance Attribute Summary

Attributes inherited from SPARQL::Algebra::Operator

#operands, #options

Instance Method Summary collapse

Methods included from Evaluatable

#evaluate, #memoize

Methods inherited from Unary

#initialize

Methods inherited from SPARQL::Algebra::Operator

arity, #base_uri, base_uri, base_uri=, #boolean, #constant?, #eql?, #evaluatable?, evaluate, #executable?, for, #initialize, #inspect, #operand, #optimize, #prefixes, prefixes, prefixes=, #to_sse, #to_sxp, #variable?

Methods included from Expression

cast, #constant?, #evaluate, for, new, open, #optimize, parse, #to_sse, #variable?

Constructor Details

This class inherits a constructor from SPARQL::Algebra::Operator::Unary

Instance Method Details

#apply(literal) ⇒ RDF::Literal

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

If the operand has no language tag, returns "".

Raises:

  • (TypeError)

    if the operand is not a literal



21
22
23
24
25
26
# File 'lib/sparql/algebra/operator/lang.rb', line 21

def apply(literal)
  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