Class: Wongi::Engine::DSL::Clause::Has

Inherits:
Struct
  • Object
show all
Includes:
CoreExt
Defined in:
lib/wongi-engine/dsl/clause/fact.rb

Direct Known Subclasses

Neg, Opt

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from CoreExt

included

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, options = { })
  time = options[:time] || 0
  @unsafe = options[:unsafe] || false
  debug! if options[: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

#objectObject

Returns the value of attribute object

Returns:

  • (Object)

    the current value of object



3
4
5
# File 'lib/wongi-engine/dsl/clause/fact.rb', line 3

def object
  @object
end

#predicateObject

Returns the value of attribute predicate

Returns:

  • (Object)

    the current value of predicate



3
4
5
# File 'lib/wongi-engine/dsl/clause/fact.rb', line 3

def predicate
  @predicate
end

#subjectObject

Returns the value of attribute subject

Returns:

  • (Object)

    the current value of subject



3
4
5
# File 'lib/wongi-engine/dsl/clause/fact.rb', line 3

def subject
  @subject
end

#timeObject

Returns the value of attribute time

Returns:

  • (Object)

    the current value of 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

#inspectObject



21
22
23
# File 'lib/wongi-engine/dsl/clause/fact.rb', line 21

def inspect
  "<+#{subject.inspect} #{predicate.inspect} #{object.inspect}>"
end