Class: ConceptAI
Overview
ConceptAI: Add more info to every Concept instance.
Encapsulating AI data => questions
-
concept
-
questions
-
num
-
random_image_for
Instance Attribute Summary collapse
-
#concept ⇒ Object
readonly
Returns the value of attribute concept.
-
#excluded_questions ⇒ Object
readonly
Returns the value of attribute excluded_questions.
-
#questions ⇒ Object
readonly
Returns the value of attribute questions.
Instance Method Summary collapse
-
#initialize(concept, world) ⇒ ConceptAI
constructor
Initialize ConcepAI.
-
#method_missing(method, *args, &block) ⇒ Object
If a method call is missing, then delegate to concept parent.
-
#num ⇒ Object
Generates and return new “num” value.
-
#random_image_for(_conceptname) ⇒ Object
Generates random image URL.
Methods included from AI
#exclude_questions, #make_questions, #make_questions_stages_bsf, #make_questions_stages_di, #make_questions_stages_t, #string_has_this_tags?
Methods included from AICalculate
#calculate_nearness_between_texts, #get_list1_and_list2_from, #reorder_list_with_row
Constructor Details
#initialize(concept, world) ⇒ ConceptAI
Initialize ConcepAI
24 25 26 27 28 29 30 31 |
# File 'lib/asker/ai/concept_ai.rb', line 24 def initialize(concept, world) @concept = concept @world = world @questions = { d: [], b: [], f: [], i: [], s: [], t: [] } @excluded_questions = { d: [], b: [], f: [], i: [], s: [], t: [] } @num = 0 # Add a unique number to every question make_questions end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
If a method call is missing, then delegate to concept parent.
41 42 43 44 |
# File 'lib/asker/ai/concept_ai.rb', line 41 def method_missing(method, *args, &block) raise "[DEBUG] ConceptAI.#{method}(#{args})" @concept.send(method, *args, &block) end |
Instance Attribute Details
#concept ⇒ Object (readonly)
Returns the value of attribute concept.
16 17 18 |
# File 'lib/asker/ai/concept_ai.rb', line 16 def concept @concept end |
#excluded_questions ⇒ Object (readonly)
Returns the value of attribute excluded_questions.
18 19 20 |
# File 'lib/asker/ai/concept_ai.rb', line 18 def excluded_questions @excluded_questions end |
#questions ⇒ Object (readonly)
Returns the value of attribute questions.
17 18 19 |
# File 'lib/asker/ai/concept_ai.rb', line 17 def questions @questions end |
Instance Method Details
#num ⇒ Object
Generates and return new “num” value
35 36 37 38 |
# File 'lib/asker/ai/concept_ai.rb', line 35 def num @num += 1 @num.to_s end |
#random_image_for(_conceptname) ⇒ Object
Generates random image URL
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/asker/ai/concept_ai.rb', line 48 def random_image_for(_conceptname) return '' if rand <= ProjectData.instance.get(:threshold) keys = @world.image_urls.keys keys.shuffle! values = @world.image_urls[keys[0]] # keys[0] could be conceptname return '' if values.nil? values.shuffle! "<img src=\"#{values[0]}\" alt=\"image\"><br/>" end |