Class: Legion::Extensions::Agentic::Executive::FlexibilityTraining::Helpers::TrainingTask

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/extensions/agentic/executive/flexibility_training/helpers/training_task.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, domain:, difficulty:) ⇒ TrainingTask

Returns a new instance of TrainingTask.



14
15
16
17
18
19
20
21
22
# File 'lib/legion/extensions/agentic/executive/flexibility_training/helpers/training_task.rb', line 14

def initialize(name:, domain:, difficulty:)
  @id                   = SecureRandom.uuid
  @name                 = name
  @domain               = domain
  @difficulty           = difficulty.clamp(0.0, 1.0).round(10)
  @baseline_performance = (1.0 - (@difficulty * 0.4)).clamp(0.0, 1.0).round(10)
  @practice_count       = 0
  @created_at           = Time.now.utc
end

Instance Attribute Details

#baseline_performanceObject (readonly)

Returns the value of attribute baseline_performance.



12
13
14
# File 'lib/legion/extensions/agentic/executive/flexibility_training/helpers/training_task.rb', line 12

def baseline_performance
  @baseline_performance
end

#created_atObject (readonly)

Returns the value of attribute created_at.



12
13
14
# File 'lib/legion/extensions/agentic/executive/flexibility_training/helpers/training_task.rb', line 12

def created_at
  @created_at
end

#difficultyObject (readonly)

Returns the value of attribute difficulty.



12
13
14
# File 'lib/legion/extensions/agentic/executive/flexibility_training/helpers/training_task.rb', line 12

def difficulty
  @difficulty
end

#domainObject (readonly)

Returns the value of attribute domain.



12
13
14
# File 'lib/legion/extensions/agentic/executive/flexibility_training/helpers/training_task.rb', line 12

def domain
  @domain
end

#idObject (readonly)

Returns the value of attribute id.



12
13
14
# File 'lib/legion/extensions/agentic/executive/flexibility_training/helpers/training_task.rb', line 12

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



12
13
14
# File 'lib/legion/extensions/agentic/executive/flexibility_training/helpers/training_task.rb', line 12

def name
  @name
end

#practice_countObject (readonly)

Returns the value of attribute practice_count.



12
13
14
# File 'lib/legion/extensions/agentic/executive/flexibility_training/helpers/training_task.rb', line 12

def practice_count
  @practice_count
end

Instance Method Details

#difficulty_labelObject



31
32
33
34
# File 'lib/legion/extensions/agentic/executive/flexibility_training/helpers/training_task.rb', line 31

def difficulty_label
  index = (@difficulty * (Constants::DIFFICULTY_LEVELS.size - 1)).round
  Constants::DIFFICULTY_LEVELS[index]
end

#practice!Object



24
25
26
27
28
29
# File 'lib/legion/extensions/agentic/executive/flexibility_training/helpers/training_task.rb', line 24

def practice!
  @practice_count += 1
  improvement = (Constants::IMPROVEMENT_RATE / (1.0 + (@practice_count * 0.1))).round(10)
  @baseline_performance = [(@baseline_performance + improvement), 1.0].min.round(10)
  self
end

#to_hObject



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/legion/extensions/agentic/executive/flexibility_training/helpers/training_task.rb', line 36

def to_h
  {
    id:                   @id,
    name:                 @name,
    domain:               @domain,
    difficulty:           @difficulty,
    baseline_performance: @baseline_performance,
    practice_count:       @practice_count,
    difficulty_label:     difficulty_label,
    created_at:           @created_at
  }
end