Class: Legion::Extensions::Agentic::Social::Apprenticeship::Helpers::Apprenticeship
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Social::Apprenticeship::Helpers::Apprenticeship
- Includes:
- ApprenticeshipModel
- Defined in:
- lib/legion/extensions/agentic/social/apprenticeship/helpers/apprenticeship.rb
Constant Summary
Constants included from ApprenticeshipModel
Legion::Extensions::Agentic::Social::Apprenticeship::Helpers::ApprenticeshipModel::COACHING_MULTIPLIER, Legion::Extensions::Agentic::Social::Apprenticeship::Helpers::ApprenticeshipModel::DECAY_RATE, Legion::Extensions::Agentic::Social::Apprenticeship::Helpers::ApprenticeshipModel::DEFAULT_MASTERY, Legion::Extensions::Agentic::Social::Apprenticeship::Helpers::ApprenticeshipModel::EXPLORATION_MULTIPLIER, Legion::Extensions::Agentic::Social::Apprenticeship::Helpers::ApprenticeshipModel::LEARNING_GAIN, Legion::Extensions::Agentic::Social::Apprenticeship::Helpers::ApprenticeshipModel::MASTERY_CEILING, Legion::Extensions::Agentic::Social::Apprenticeship::Helpers::ApprenticeshipModel::MASTERY_FLOOR, Legion::Extensions::Agentic::Social::Apprenticeship::Helpers::ApprenticeshipModel::MASTERY_LABELS, Legion::Extensions::Agentic::Social::Apprenticeship::Helpers::ApprenticeshipModel::MASTERY_THRESHOLD, Legion::Extensions::Agentic::Social::Apprenticeship::Helpers::ApprenticeshipModel::MAX_APPRENTICESHIPS, Legion::Extensions::Agentic::Social::Apprenticeship::Helpers::ApprenticeshipModel::MAX_HISTORY, Legion::Extensions::Agentic::Social::Apprenticeship::Helpers::ApprenticeshipModel::MAX_SESSIONS, Legion::Extensions::Agentic::Social::Apprenticeship::Helpers::ApprenticeshipModel::METHODS, Legion::Extensions::Agentic::Social::Apprenticeship::Helpers::ApprenticeshipModel::PHASE_LABELS, Legion::Extensions::Agentic::Social::Apprenticeship::Helpers::ApprenticeshipModel::PHASE_THRESHOLD
Instance Attribute Summary collapse
-
#apprentice_id ⇒ Object
readonly
Returns the value of attribute apprentice_id.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#last_session_at ⇒ Object
readonly
Returns the value of attribute last_session_at.
-
#mastery ⇒ Object
readonly
Returns the value of attribute mastery.
-
#mentor_id ⇒ Object
readonly
Returns the value of attribute mentor_id.
-
#session_count ⇒ Object
readonly
Returns the value of attribute session_count.
-
#skill_name ⇒ Object
readonly
Returns the value of attribute skill_name.
Instance Method Summary collapse
- #current_phase ⇒ Object
- #decay! ⇒ Object
- #graduated? ⇒ Boolean
-
#initialize(skill_name:, domain:, mentor_id:, apprentice_id:) ⇒ Apprenticeship
constructor
A new instance of Apprenticeship.
- #learn!(method:, success:) ⇒ Object
- #mastery_label ⇒ Object
- #recommended_method ⇒ Object
- #to_h ⇒ Object
Methods included from ApprenticeshipModel
clamp_mastery, mastery_label_for, new_apprenticeship, phase_for
Constructor Details
#initialize(skill_name:, domain:, mentor_id:, apprentice_id:) ⇒ Apprenticeship
Returns a new instance of Apprenticeship.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/legion/extensions/agentic/social/apprenticeship/helpers/apprenticeship.rb', line 15 def initialize(skill_name:, domain:, mentor_id:, apprentice_id:) data = ApprenticeshipModel.new_apprenticeship( skill_name: skill_name, domain: domain, mentor_id: mentor_id, apprentice_id: apprentice_id ) @id = data[:id] @skill_name = data[:skill_name] @domain = data[:domain] @mentor_id = data[:mentor_id] @apprentice_id = data[:apprentice_id] @mastery = data[:mastery] @session_count = data[:session_count] @created_at = data[:created_at] @last_session_at = data[:last_session_at] end |
Instance Attribute Details
#apprentice_id ⇒ Object (readonly)
Returns the value of attribute apprentice_id.
12 13 14 |
# File 'lib/legion/extensions/agentic/social/apprenticeship/helpers/apprenticeship.rb', line 12 def apprentice_id @apprentice_id end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
12 13 14 |
# File 'lib/legion/extensions/agentic/social/apprenticeship/helpers/apprenticeship.rb', line 12 def created_at @created_at end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
12 13 14 |
# File 'lib/legion/extensions/agentic/social/apprenticeship/helpers/apprenticeship.rb', line 12 def domain @domain end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/legion/extensions/agentic/social/apprenticeship/helpers/apprenticeship.rb', line 12 def id @id end |
#last_session_at ⇒ Object (readonly)
Returns the value of attribute last_session_at.
12 13 14 |
# File 'lib/legion/extensions/agentic/social/apprenticeship/helpers/apprenticeship.rb', line 12 def last_session_at @last_session_at end |
#mastery ⇒ Object (readonly)
Returns the value of attribute mastery.
12 13 14 |
# File 'lib/legion/extensions/agentic/social/apprenticeship/helpers/apprenticeship.rb', line 12 def mastery @mastery end |
#mentor_id ⇒ Object (readonly)
Returns the value of attribute mentor_id.
12 13 14 |
# File 'lib/legion/extensions/agentic/social/apprenticeship/helpers/apprenticeship.rb', line 12 def mentor_id @mentor_id end |
#session_count ⇒ Object (readonly)
Returns the value of attribute session_count.
12 13 14 |
# File 'lib/legion/extensions/agentic/social/apprenticeship/helpers/apprenticeship.rb', line 12 def session_count @session_count end |
#skill_name ⇒ Object (readonly)
Returns the value of attribute skill_name.
12 13 14 |
# File 'lib/legion/extensions/agentic/social/apprenticeship/helpers/apprenticeship.rb', line 12 def skill_name @skill_name end |
Instance Method Details
#current_phase ⇒ Object
33 34 35 |
# File 'lib/legion/extensions/agentic/social/apprenticeship/helpers/apprenticeship.rb', line 33 def current_phase ApprenticeshipModel.phase_for(@mastery) end |
#decay! ⇒ Object
63 64 65 66 |
# File 'lib/legion/extensions/agentic/social/apprenticeship/helpers/apprenticeship.rb', line 63 def decay! @mastery = ApprenticeshipModel.clamp_mastery(@mastery - ApprenticeshipModel::DECAY_RATE) self end |
#graduated? ⇒ Boolean
41 42 43 |
# File 'lib/legion/extensions/agentic/social/apprenticeship/helpers/apprenticeship.rb', line 41 def graduated? @mastery >= ApprenticeshipModel::MASTERY_THRESHOLD end |
#learn!(method:, success:) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/legion/extensions/agentic/social/apprenticeship/helpers/apprenticeship.rb', line 49 def learn!(method:, success:) multiplier = case method when :exploration then ApprenticeshipModel::EXPLORATION_MULTIPLIER when :coaching then ApprenticeshipModel::COACHING_MULTIPLIER else 1.0 end gain = success ? ApprenticeshipModel::LEARNING_GAIN * multiplier : 0.0 @mastery = ApprenticeshipModel.clamp_mastery(@mastery + gain) @session_count += 1 @last_session_at = Time.now.utc self end |
#mastery_label ⇒ Object
37 38 39 |
# File 'lib/legion/extensions/agentic/social/apprenticeship/helpers/apprenticeship.rb', line 37 def mastery_label ApprenticeshipModel.mastery_label_for(@mastery) end |
#recommended_method ⇒ Object
45 46 47 |
# File 'lib/legion/extensions/agentic/social/apprenticeship/helpers/apprenticeship.rb', line 45 def recommended_method ApprenticeshipModel.phase_for(@mastery) end |
#to_h ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/legion/extensions/agentic/social/apprenticeship/helpers/apprenticeship.rb', line 68 def to_h { id: @id, skill_name: @skill_name, domain: @domain, mentor_id: @mentor_id, apprentice_id: @apprentice_id, mastery: @mastery, current_phase: current_phase, mastery_label: mastery_label, graduated: graduated?, session_count: @session_count, created_at: @created_at, last_session_at: @last_session_at } end |