-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preliminary support for isTriple, Triple, Subject, Predicate, and Obj…
…ect builtin operators.
- Loading branch information
Showing
13 changed files
with
5,638 additions
and
2,427 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module SPARQL; module Algebra | ||
class Operator | ||
## | ||
# The SPARQL `isTriple` operator. | ||
# | ||
# @see xxx | ||
class IsTriple < Operator::Unary | ||
include Evaluatable | ||
|
||
NAME = :isTriple | ||
|
||
## | ||
# Returns `true` if the operand is an `RDF::Statement`, `false` otherwise. | ||
# | ||
# @param [RDF::Term] term | ||
# an RDF term | ||
# @return [RDF::Literal::Boolean] `true` or `false` | ||
# @raise [TypeError] if the operand is not an RDF term | ||
def apply(term) | ||
case term | ||
when RDF::Statement then RDF::Literal::TRUE | ||
when RDF::Term then RDF::Literal::FALSE | ||
else raise TypeError, "expected an RDF::Term, but got #{term.inspect}" | ||
end | ||
end | ||
end # IsTriple | ||
end # Operator | ||
end; end # SPARQL::Algebra |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module SPARQL; module Algebra | ||
class Operator | ||
## | ||
# The SPARQL logical `object` operator. | ||
# | ||
# Returns the object part of `arg` as a term. | ||
# | ||
# @see xxx | ||
class Object < Operator::Unary | ||
include Evaluatable | ||
|
||
NAME = :object | ||
|
||
## | ||
# Returns the object part of arg. | ||
# | ||
# @param [RDF::Statement] operand | ||
# the operand | ||
# @return [RDF::Literal] | ||
# @raise [TypeError] if the operand is not a statement | ||
def apply(operand) | ||
raise TypeError, "expected an RDF::Statement, but got #{operand.inspect}" unless operand.is_a?(RDF::Statement) | ||
operand.object | ||
end | ||
end # Object | ||
end # Operator | ||
end; end # SPARQL::Algebra |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module SPARQL; module Algebra | ||
class Operator | ||
## | ||
# The SPARQL logical `predicate` operator. | ||
# | ||
# Returns the predicate part of `arg` as a term. | ||
# | ||
# @see xxx | ||
class Predicate < Operator::Unary | ||
include Evaluatable | ||
|
||
NAME = :predicate | ||
|
||
## | ||
# Returns the predicate part of arg. | ||
# | ||
# @param [RDF::Statement] operand | ||
# the operand | ||
# @return [RDF::Literal] | ||
# @raise [TypeError] if the operand is not a statement | ||
def apply(operand) | ||
raise TypeError, "expected an RDF::Statement, but got #{operand.inspect}" unless operand.is_a?(RDF::Statement) | ||
operand.predicate | ||
end | ||
end # Predicate | ||
end # Operator | ||
end; end # SPARQL::Algebra |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module SPARQL; module Algebra | ||
class Operator | ||
## | ||
# The SPARQL logical `subject` operator. | ||
# | ||
# Returns the subject part of `arg` as a term. | ||
# | ||
# @see xxx | ||
class Subject < Operator::Unary | ||
include Evaluatable | ||
|
||
NAME = :subject | ||
|
||
## | ||
# Returns the subject part of arg. | ||
# | ||
# @param [RDF::Statement] operand | ||
# the operand | ||
# @return [RDF::Literal] | ||
# @raise [TypeError] if the operand is not a statement | ||
def apply(operand) | ||
raise TypeError, "expected an RDF::Statement, but got #{operand.inspect}" unless operand.is_a?(RDF::Statement) | ||
operand.subject | ||
end | ||
end # Subject | ||
end # Operator | ||
end; end # SPARQL::Algebra |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module SPARQL; module Algebra | ||
class Operator | ||
## | ||
# The SPARQL `triple` operator. | ||
# | ||
# @see xxx | ||
class Triple < Operator::Ternary | ||
include Evaluatable | ||
|
||
NAME = :triple | ||
|
||
## | ||
# @param [RDF::Term] subject | ||
# @param [RDF::Term] predicate | ||
# @param [RDF::Term] object | ||
# @return [RDF::URI] | ||
# @raise [TypeError] if the operand is not a simple literal | ||
def apply(subject, predicate, object) | ||
triple = RDF::Statement(subject, predicate, object) | ||
raise TypeError, "valid components, but got #{triple.inspect}" unless triple.valid? | ||
triple | ||
end | ||
end # Triple | ||
end # Operator | ||
end; end # SPARQL::Algebra |
Oops, something went wrong.