Class: Proc

Inherits:
Object show all
Includes:
Rubylog::CompoundTerm, Rubylog::Goal
Defined in:
lib/rubylog/mixins/proc.rb

Instance Attribute Summary

Attributes included from Rubylog::CompoundTerm

#rubylog_variables

Instance Method Summary collapse

Methods included from Rubylog::CompoundTerm

#rubylog_match_variables

Methods included from Rubylog::Goal

#solve, #true?

Instance Method Details

#call_with_rubylog_variables(vars = nil) ⇒ Object

Calls the proc with the given rubylog variables or with the currently available variables.



25
26
27
28
29
30
31
32
33
# File 'lib/rubylog/mixins/proc.rb', line 25

def call_with_rubylog_variables vars = nil
  vars ||= @rubylog_variables
  raise Rubylog::InvalidStateError, "Variables not matched" if not vars

  # Call the block with the variables substituted
  Rubylog::DSL::Variables.with_vars vars do
    return call
  end
end

#proveObject



6
7
8
# File 'lib/rubylog/mixins/proc.rb', line 6

def prove
  yield if call_with_rubylog_variables
end

#rubylog_clone {|dup| ... } ⇒ Object

Yields:

  • (dup)


12
13
14
# File 'lib/rubylog/mixins/proc.rb', line 12

def rubylog_clone 
  yield dup
end

#rubylog_resolve_functionObject

Term methods



19
20
21
# File 'lib/rubylog/mixins/proc.rb', line 19

def rubylog_resolve_function
  call_with_rubylog_variables
end