Class: ProgramR::Category

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

Constant Summary collapse

@@cardinality =
0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AimlTag

#inspect, #to_s

Constructor Details

#initialize(**opt) ⇒ Category

Returns a new instance of Category.


33
34
35
36
37
38
# File 'lib/programr/aiml_elements.rb', line 33

def initialize **opt
  @@cardinality += 1
  @pattern      = []
  @that         = []
  @language     = opt[:language]
end

Instance Attribute Details

#languageObject

Returns the value of attribute language


25
26
27
# File 'lib/programr/aiml_elements.rb', line 25

def language
  @language
end

#templateObject

Returns the value of attribute template


25
26
27
# File 'lib/programr/aiml_elements.rb', line 25

def template
  @template
end

#thatObject

Returns the value of attribute that


25
26
27
# File 'lib/programr/aiml_elements.rb', line 25

def that
  @that
end

#topicObject

Returns the value of attribute topic


25
26
27
# File 'lib/programr/aiml_elements.rb', line 25

def topic
  @topic
end

Class Method Details

.cardinalityObject


29
30
31
# File 'lib/programr/aiml_elements.rb', line 29

def self.cardinality
  @@cardinality
end

Instance Method Details

#add_pattern(anObj) ⇒ Object


40
41
42
# File 'lib/programr/aiml_elements.rb', line 40

def add_pattern anObj
  @pattern.push anObj
end

#add_that(anObj) ⇒ Object


44
45
46
# File 'lib/programr/aiml_elements.rb', line 44

def add_that anObj
  @that.push anObj
end

#patternsObject


48
49
50
# File 'lib/programr/aiml_elements.rb', line 48

def patterns
  @pattern.map(&:to_s).join('').split(/\s+/)
end

#thatsObject


52
53
54
# File 'lib/programr/aiml_elements.rb', line 52

def thats
  @that.map(&:to_s).join('').split(/\s+/)
end

#topicsObject


56
57
58
59
# File 'lib/programr/aiml_elements.rb', line 56

def topics
  return [] if @topic.nil?
  @topic.split(/\s+/)
end