Class: Cyc::Assertion

Inherits:
Object
  • Object
show all
Defined in:
lib/cyc/assertion.rb

Overview

Author

Aleksander Pohl ([email protected])

License

MIT/X11 License

This class represent a Cyc assertion.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(formula, microtheory) ⇒ Assertion

Initialize the assertion with a formula and a microtheory.



14
15
16
17
# File 'lib/cyc/assertion.rb', line 14

def initialize(formula,microtheory)
  @formula = formula
  @microtheory = microtheory
end

Instance Attribute Details

#formulaObject (readonly)

The logical formula of the assertion.



8
9
10
# File 'lib/cyc/assertion.rb', line 8

def formula
  @formula
end

#microtheoryObject (readonly)

The microtheory the assertion was asserted in.



11
12
13
# File 'lib/cyc/assertion.rb', line 11

def microtheory
  @microtheory
end

Instance Method Details

#==(other) ⇒ Object



29
30
31
32
33
34
# File 'lib/cyc/assertion.rb', line 29

def ==(other)
  return true if self.object_id == other.object_id
  return false unless other.respond_to?(:formula)
  return false unless other.respond_to?(:microtheory)
  self.formula == other.formula && self.microtheory == other.microtheory
end

#to_cyc(raw = false) ⇒ Object

Returns the representation of the assertion understandable by Cyc.



25
26
27
# File 'lib/cyc/assertion.rb', line 25

def to_cyc(raw=false)
  "(find-assertion (caar (el-to-hl '#{@formula.to_cyc(true)})) #{@microtheory.to_cyc})"
end

#to_sObject

Returns the string representation of the assertion.



20
21
22
# File 'lib/cyc/assertion.rb', line 20

def to_s
  "#{@formula} : #{@microtheory}"
end