Class: ProgramR::Random
- Inherits:
-
Object
- Object
- ProgramR::Random
- Defined in:
- lib/programr/aiml_elements.rb
Constant Summary collapse
- @@environment =
Environment.new
Instance Method Summary collapse
- #add(aBody) ⇒ Object
- #execute ⇒ Object (also: #to_s)
-
#initialize ⇒ Random
constructor
A new instance of Random.
- #inspect ⇒ Object
- #setListElement(someAttributes) ⇒ Object
Constructor Details
#initialize ⇒ Random
Returns a new instance of Random.
61 |
# File 'lib/programr/aiml_elements.rb', line 61 def initialize; @conditions = [] end |
Instance Method Details
#add(aBody) ⇒ Object
66 67 68 |
# File 'lib/programr/aiml_elements.rb', line 66 def add(aBody) @conditions[-1].push(aBody) end |
#execute ⇒ Object Also known as: to_s
70 71 72 73 74 75 76 |
# File 'lib/programr/aiml_elements.rb', line 70 def execute res = '' @@environment.getRandom(@conditions).each{|tocken| res += tocken.to_s } return res.strip end |
#inspect ⇒ Object
78 |
# File 'lib/programr/aiml_elements.rb', line 78 def inspect(); "random -> #{execute}" end |
#setListElement(someAttributes) ⇒ Object
62 63 64 |
# File 'lib/programr/aiml_elements.rb', line 62 def setListElement(someAttributes) @conditions.push([]) end |