Class: RubyProlog::Goal
- Inherits:
-
Object
- Object
- RubyProlog::Goal
- Defined in:
- lib/ruby-prolog/ruby-prolog.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#pred ⇒ Object
readonly
Returns the value of attribute pred.
Instance Method Summary collapse
- #<<(rhs) ⇒ Object
- #calls(&callback) ⇒ Object
- #fact ⇒ Object
-
#initialize(pred, args) ⇒ Goal
constructor
A new instance of Goal.
- #inspect ⇒ Object
- #list(*x) ⇒ Object
- #si(*rhs) ⇒ Object
Constructor Details
#initialize(pred, args) ⇒ Goal
Returns a new instance of Goal.
38 39 40 |
# File 'lib/ruby-prolog/ruby-prolog.rb', line 38 def initialize(pred, args) @pred, @args = pred, args end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
30 31 32 |
# File 'lib/ruby-prolog/ruby-prolog.rb', line 30 def args @args end |
#pred ⇒ Object (readonly)
Returns the value of attribute pred.
30 31 32 |
# File 'lib/ruby-prolog/ruby-prolog.rb', line 30 def pred @pred end |
Instance Method Details
#<<(rhs) ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/ruby-prolog/ruby-prolog.rb', line 50 def <<(rhs) case rhs when Array si(*rhs) else si(rhs) end end |
#calls(&callback) ⇒ Object
59 60 61 |
# File 'lib/ruby-prolog/ruby-prolog.rb', line 59 def calls(&callback) @pred.defs << [self, callback] end |
#fact ⇒ Object
46 47 48 |
# File 'lib/ruby-prolog/ruby-prolog.rb', line 46 def fact si end |
#inspect ⇒ Object
63 64 65 |
# File 'lib/ruby-prolog/ruby-prolog.rb', line 63 def inspect return @pred.inspect.to_s + @args.inspect.to_s end |
#list(*x) ⇒ Object
32 33 34 35 36 |
# File 'lib/ruby-prolog/ruby-prolog.rb', line 32 def list(*x) y = nil x.reverse_each {|e| y = Cons.new(e, y)} return y end |
#si(*rhs) ⇒ Object
42 43 44 |
# File 'lib/ruby-prolog/ruby-prolog.rb', line 42 def si(*rhs) @pred.defs << [self, list(*rhs)] end |