Class: ProgramR::Person
- Inherits:
-
Object
- Object
- ProgramR::Person
- Defined in:
- lib/programr/aiml_elements.rb
Constant Summary collapse
- @@environment =
Environment.new
- @@swap =
{'male' => {'me' => 'him', 'my' => 'his', 'myself' => 'himself', 'mine' => 'his', 'i' => 'he', 'he' => 'i', 'she' => 'i'}, 'female' => {'me' => 'her', 'my' => 'her', 'myself' => 'herself', 'mine' => 'hers', 'i' => 'she', 'he' => 'i', 'she' => 'i'}}
Instance Method Summary collapse
- #add(anObj) ⇒ Object
- #execute ⇒ Object (also: #to_s)
-
#initialize ⇒ Person
constructor
A new instance of Person.
- #inspect ⇒ Object
Constructor Details
#initialize ⇒ Person
Returns a new instance of Person.
301 |
# File 'lib/programr/aiml_elements.rb', line 301 def initialize; @sentence = [] end |
Instance Method Details
#add(anObj) ⇒ Object
302 |
# File 'lib/programr/aiml_elements.rb', line 302 def add(anObj); @sentence.push(anObj) end |
#execute ⇒ Object Also known as: to_s
303 304 305 306 307 308 309 310 311 312 |
# File 'lib/programr/aiml_elements.rb', line 303 def execute res = '' @sentence.each{|tocken| res += tocken.to_s } gender = @@environment.get('gender') res.gsub(/\b(she|he|i|me|my|myself|mine)\b/i){ @@swap[gender][$1.downcase] } end |
#inspect ⇒ Object
314 |
# File 'lib/programr/aiml_elements.rb', line 314 def inspect(); "person-> #{execute}" end |