class RDF::N3::Algebra::Math::Tan

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

@see www.w3.org/TR/xpath-functions/#func-math-tan

Constants

NAME
URI

Public Instance Methods

input_operand() click to toggle source

Input is either the subject or object

@return [RDF::Term]

# File lib/rdf/n3/algebra/math/tan.rb, line 36
def input_operand
  RDF::N3::List.new(values: operands)
end
resolve(resource, position:) click to toggle source

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.

@param [RDF::Term] resource @param [:subject, :object] position @return [RDF::Term] @see RDF::N3::ResourceOperator#evaluate

# 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