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
# File 'lib/wongi-engine/dsl/clause/fact.rb', line 7

def initialize(s, p, o, options = {})
  debug! if options[:debug]
  super(s, p, o)
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

Instance Method Details

#compile(context) ⇒ Object



12
13
14
15
# File 'lib/wongi-engine/dsl/clause/fact.rb', line 12

def compile(context)
  tests, assignment = parse_variables(context)
  context.tap { |c| c.join_node(self, tests, assignment) }
end

#inspectObject



17
18
19
# File 'lib/wongi-engine/dsl/clause/fact.rb', line 17

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