Class: Sfp::Axiom
- Inherits:
-
Hash
- Object
- Hash
- Sfp::Axiom
- Defined in:
- lib/sfp/sas_translator.rb
Overview
A class for Grounded Axiom
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#target ⇒ Object
Returns the value of attribute target.
Instance Method Summary collapse
-
#initialize ⇒ Axiom
constructor
A new instance of Axiom.
- #to_s ⇒ Object
- #to_sas(root, variables) ⇒ Object
Constructor Details
#initialize ⇒ Axiom
Returns a new instance of Axiom.
2154 2155 2156 |
# File 'lib/sfp/sas_translator.rb', line 2154 def initialize @id = Sfp::SasTranslator.next_axiom_id end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
2152 2153 2154 |
# File 'lib/sfp/sas_translator.rb', line 2152 def id @id end |
#target ⇒ Object
Returns the value of attribute target.
2152 2153 2154 |
# File 'lib/sfp/sas_translator.rb', line 2152 def target @target end |
Instance Method Details
#to_s ⇒ Object
2158 2159 2160 |
# File 'lib/sfp/sas_translator.rb', line 2158 def to_s return 'axiom#' + @id.to_s end |
#to_sas(root, variables) ⇒ Object
2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 |
# File 'lib/sfp/sas_translator.rb', line 2162 def to_sas(root, variables) prevails = select { |var,param| param.post.nil? } preposts = select { |var,param| !param.post.nil? } raise Exception, "Invalid axiom: total preposts > 1" if preposts.length > 1 raise Exception, "Invalid axiom: total preposts <= 0" if preposts.length <= 0 sas = "begin_rule" sas << "\n#{prevails.length}" prevails.each { |var,param| sas << "\n#{param.to_sas(root, variables)}" } preposts.each { |var,param| sas << "\n#{param.to_sas(root, variables)}" } sas << "\nend_rule" return sas end |