Class: RDF::N3::Algebra::Math::Tan

Inherits:
ResourceOperator
  • Object
show all
Defined in:
lib/rdf/n3/algebra/math/tan.rb

Overview

The subject is an angle expressed in radians. The object is calulated as the tangent value of the subject.

Constant Summary collapse

NAME =
:mathTan
URI =
RDF::N3::Math.tan

Instance Attribute Summary

Attributes included from Enumerable

#existentials, #universals

Instance Method Summary collapse

Methods inherited from ResourceOperator

#as_literal, #execute, #valid?

Methods included from Builtin

#each, #evaluate, #hash, #rank, #to_uri

Instance Method Details

#input_operandRDF::Term

Input is either the subject or object

Returns:



36
37
38
# File 'lib/rdf/n3/algebra/math/tan.rb', line 36

def input_operand
  RDF::N3::List.new(values: operands)
end

#resolve(resource, position:) ⇒ RDF::Term

The math:tan operator takes string or number and calculates its tangent. The arc tangent of a concrete object can also calculate a variable subject.

Parameters:

  • resource (RDF::Term)
  • position (:subject, :object)

Returns:

See Also:

  • ResourceOperator#evaluate


17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rdf/n3/algebra/math/tan.rb', line 17

def resolve(resource, position:)
  case resource
  when RDF::Query::Variable then resource
  when RDF::Literal
    case position
    when :subject
      as_literal(Math.tan(resource.as_number.object))
    when :object
      as_literal(Math.atan(resource.as_number.object))
    end
  else
    nil
  end
end