class Porolog::Scope
A Porolog::Scope
is a container for Porolog::Predicates. Its purpose is to allow a Ruby program to contain multiple Prolog programs without the Prolog programs interfering with each other. @author Luis Esteban @!attribute [r] name
Name of the Scope.
Attributes
Public Class Methods
Initializes and registers the Scope
. @param name [Object] the name (or otherwise object) used to register a scope.
# File lib/porolog/scope.rb, line 34 def initialize(name) @name = name @predicates = {} @@scopes[@name] = self end
Returns the names of all registered Scopes. @return [Array<Symbol>] the names if scopes are named as Symbols (the intended case). @return [Array<Object>] the names if the names are not actually Symbols.
# File lib/porolog/scope.rb, line 60 def self.scopes @@scopes.keys end
Public Instance Methods
Assigns a Predicate
to the Scope
by its name. @param name [Object] the name (or otherwise object) used to register a scope. @param predicate [Porolog::Predicate] a Predicate
to be assigned to the Scope
. @return [Porolog::Predicate] the Predicate
assigned to the Scope
. @raise [NotPredicateError] when provided predicate is not actually a Predicate
.
# File lib/porolog/scope.rb, line 76 def []=(name, predicate) raise NotPredicateError, "#{predicate.inspect} is not a Predicate" unless predicate.is_a?(Predicate) @predicates[name.to_sym] = predicate end