Class: Wongi::Engine::DSL::Clause::Has
- Inherits:
-
Struct
- Object
- Struct
- Wongi::Engine::DSL::Clause::Has
- Includes:
- CoreExt
- Defined in:
- lib/wongi-engine/dsl/clause/fact.rb
Instance Attribute Summary collapse
-
#object ⇒ Object
Returns the value of attribute object.
-
#predicate ⇒ Object
Returns the value of attribute predicate.
-
#subject ⇒ Object
Returns the value of attribute subject.
-
#time ⇒ Object
Returns the value of attribute time.
Instance Method Summary collapse
- #compile(context) ⇒ Object
-
#initialize(s, p, o, options = { }) ⇒ Has
constructor
A new instance of Has.
- #inspect ⇒ Object
Methods included from CoreExt
Constructor Details
#initialize(s, p, o, options = { }) ⇒ Has
Returns a new instance of Has.
7 8 9 10 11 12 13 14 |
# File 'lib/wongi-engine/dsl/clause/fact.rb', line 7 def initialize(s, p, o, = { }) time = [:time] || 0 @unsafe = [:unsafe] || false debug! if [:debug] raise "Cannot work with continuous time" unless time.integer? raise "Cannot look into the future" if time > 0 super(s, p, o, time) end |
Instance Attribute Details
#object ⇒ Object
Returns the value of attribute object
3 4 5 |
# File 'lib/wongi-engine/dsl/clause/fact.rb', line 3 def object @object end |
#predicate ⇒ Object
Returns the value of attribute predicate
3 4 5 |
# File 'lib/wongi-engine/dsl/clause/fact.rb', line 3 def predicate @predicate end |
#subject ⇒ Object
Returns the value of attribute subject
3 4 5 |
# File 'lib/wongi-engine/dsl/clause/fact.rb', line 3 def subject @subject end |
#time ⇒ Object
Returns the value of attribute time
3 4 5 |
# File 'lib/wongi-engine/dsl/clause/fact.rb', line 3 def time @time end |
Instance Method Details
#compile(context) ⇒ Object
16 17 18 19 |
# File 'lib/wongi-engine/dsl/clause/fact.rb', line 16 def compile(context) tests, assignment = parse_variables(context) context.tap { |c| c.join_node(self, tests, assignment) } end |
#inspect ⇒ Object
21 22 23 |
# File 'lib/wongi-engine/dsl/clause/fact.rb', line 21 def inspect "<+#{subject.inspect} #{predicate.inspect} #{object.inspect}>" end |