Class: ProgramR::SetTag
- Inherits:
-
Object
- Object
- ProgramR::SetTag
- 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(aLocalname, attributes) ⇒ SetTag
constructor
A new instance of SetTag.
- #inspect ⇒ Object
Constructor Details
#initialize(aLocalname, attributes) ⇒ SetTag
Returns a new instance of SetTag.
144 145 146 147 148 149 150 151 |
# File 'lib/programr/aiml_elements.rb', line 144 def initialize(aLocalname,attributes) if(attributes.empty?) @localname = aLocalname.sub(/^set_/,'') else @localname = attributes['name'] end @value = [] end |
Instance Method Details
#add(aBody) ⇒ Object
153 154 155 |
# File 'lib/programr/aiml_elements.rb', line 153 def add(aBody) @value.push(aBody) end |
#execute ⇒ Object Also known as: to_s
157 158 159 160 161 162 163 |
# File 'lib/programr/aiml_elements.rb', line 157 def execute res = '' @value.each{|tocken| res += tocken.to_s } @@environment.set(@localname,res.strip) end |
#inspect ⇒ Object
165 |
# File 'lib/programr/aiml_elements.rb', line 165 def inspect(); "set tag #{@localname} -> #{execute}" end |