Class: ProgramR::SetTag

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

Instance Method Summary collapse

Methods inherited from AimlTag

#inspect, #to_s

Constructor Details

#initialize(aLocalname, attributes, environment) ⇒ SetTag

Returns a new instance of SetTag.


239
240
241
242
243
244
245
246
247
# File 'lib/programr/aiml_elements.rb', line 239

def initialize aLocalname, attributes, environment
  @environment = environment
  @value = []
  if attributes['name'].nil?
    @localname = aLocalname.sub(/^set_/, '')
  else
    @localname = attributes['name']
  end
end

Instance Method Details

#add(aBody) ⇒ Object


249
250
251
# File 'lib/programr/aiml_elements.rb', line 249

def add aBody
  @value.push(aBody)
end

#executeObject


257
258
259
260
# File 'lib/programr/aiml_elements.rb', line 257

def execute
  @environment.set(@localname, value)
  to_response value
end

#valueObject


253
254
255
# File 'lib/programr/aiml_elements.rb', line 253

def value
  @value.map(&:to_s).join('').strip
end