Sha256: 0ea5f483eb861aa3187e09a8a62abdf131b96b7cd00177a1951276264c087bf9
Contents?: true
Size: 1013 Bytes
Versions: 5
Compression:
Stored size: 1013 Bytes
Contents
module SPARQL; module Algebra class Operator ## # The SPARQL numeric `subtract` operator. # (- ?x ?y) # (subtract ?x ?y) # # @see https://www.w3.org/TR/xpath-functions/#func-numeric-subtract class Subtract < Operator::Binary include Evaluatable NAME = [:-, :subtract] ## # Returns the arithmetic difference of the operands. # # @param [RDF::Literal::Numeric] left # a numeric literal # @param [RDF::Literal::Numeric] right # a numeric literal # @return [RDF::Literal::Numeric] # @raise [TypeError] if either operand is not a numeric literal def apply(left, right) case when left.is_a?(RDF::Literal::Numeric) && right.is_a?(RDF::Literal::Numeric) left - right else raise TypeError, "expected two RDF::Literal::Numeric operands, but got #{left.inspect} and #{right.inspect}" end end end # Subtract end # Operator end; end # SPARQL::Algebra
Version data entries
5 entries across 5 versions & 1 rubygems