Class: ProgramR::ListCondition

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Condition

#condition_valid?

Methods inherited from AimlTag

#inspect, #to_s

Constructor Details

#initialize(someAttributes) ⇒ ListCondition

Returns a new instance of ListCondition.


169
170
171
172
# File 'lib/programr/aiml_elements.rb', line 169

def initialize someAttributes
  @condition_items = []
  @property = someAttributes['name'] if someAttributes.has_key? 'name'
end

Instance Attribute Details

#propertyObject (readonly)

Returns the value of attribute property


167
168
169
# File 'lib/programr/aiml_elements.rb', line 167

def property
  @property
end

Instance Method Details

#add(text) ⇒ Object


174
175
176
# File 'lib/programr/aiml_elements.rb', line 174

def add text
  @condition_items[-1].add text
end

#executeObject


182
183
184
185
186
187
# File 'lib/programr/aiml_elements.rb', line 182

def execute
  @condition_items.each do |item|
    return item.execute if item.condition_valid?
  end
  default_item_result || to_response
end

#setListElement(condition_item) ⇒ Object


178
179
180
# File 'lib/programr/aiml_elements.rb', line 178

def setListElement condition_item
  @condition_items << condition_item
end