Class: ProgramR::SetTag

Inherits:
Object
  • Object
show all
Defined in:
lib/programr/aiml_elements.rb

Constant Summary collapse

@@environment =
Environment.new

Instance Method Summary collapse

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

#executeObject 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

#inspectObject



165
# File 'lib/programr/aiml_elements.rb', line 165

def inspect(); "set tag #{@localname} -> #{execute}" end