Class: Legion::Extensions::Agentic::Social::MoralReasoning::Helpers::Dilemma
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Social::MoralReasoning::Helpers::Dilemma
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb
Constant Summary
Constants included from Constants
Constants::DECAY_RATE, Constants::DEFAULT_WEIGHT, Constants::ETHICAL_FRAMEWORKS, Constants::KOHLBERG_LEVELS, Constants::KOHLBERG_STAGES, Constants::MAX_DILEMMAS, Constants::MAX_HISTORY, Constants::MAX_PRINCIPLES, Constants::MORAL_FOUNDATIONS, Constants::REINFORCEMENT_RATE, Constants::SEVERITY_LABELS, Constants::WEIGHT_CEILING, Constants::WEIGHT_FLOOR
Instance Attribute Summary collapse
-
#chosen_option ⇒ Object
readonly
Returns the value of attribute chosen_option.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#framework_used ⇒ Object
readonly
Returns the value of attribute framework_used.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#reasoning ⇒ Object
readonly
Returns the value of attribute reasoning.
-
#resolved_at ⇒ Object
readonly
Returns the value of attribute resolved_at.
-
#severity ⇒ Object
readonly
Returns the value of attribute severity.
Instance Method Summary collapse
-
#initialize(id:, description:, options:, domain: :general, severity: 0.5) ⇒ Dilemma
constructor
A new instance of Dilemma.
- #resolve(option_id:, reasoning:, framework:) ⇒ Object
- #resolved? ⇒ Boolean
- #severity_label ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(id:, description:, options:, domain: :general, severity: 0.5) ⇒ Dilemma
Returns a new instance of Dilemma.
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb', line 16 def initialize(id:, description:, options:, domain: :general, severity: 0.5) @id = id @description = description @domain = domain @severity = severity.clamp(0.0, 1.0) @options = @chosen_option = nil @reasoning = nil @framework_used = nil @resolved = false @created_at = Time.now.utc @resolved_at = nil end |
Instance Attribute Details
#chosen_option ⇒ Object (readonly)
Returns the value of attribute chosen_option.
12 13 14 |
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb', line 12 def chosen_option @chosen_option end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
12 13 14 |
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb', line 12 def created_at @created_at end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
12 13 14 |
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb', line 12 def description @description end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
12 13 14 |
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb', line 12 def domain @domain end |
#framework_used ⇒ Object (readonly)
Returns the value of attribute framework_used.
12 13 14 |
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb', line 12 def framework_used @framework_used end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb', line 12 def id @id end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
12 13 14 |
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb', line 12 def @options end |
#reasoning ⇒ Object (readonly)
Returns the value of attribute reasoning.
12 13 14 |
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb', line 12 def reasoning @reasoning end |
#resolved_at ⇒ Object (readonly)
Returns the value of attribute resolved_at.
12 13 14 |
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb', line 12 def resolved_at @resolved_at end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
12 13 14 |
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb', line 12 def severity @severity end |
Instance Method Details
#resolve(option_id:, reasoning:, framework:) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb', line 34 def resolve(option_id:, reasoning:, framework:) @chosen_option = option_id @reasoning = reasoning @framework_used = framework @resolved = true @resolved_at = Time.now.utc end |
#resolved? ⇒ Boolean
42 43 44 |
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb', line 42 def resolved? @resolved end |
#severity_label ⇒ Object
30 31 32 |
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb', line 30 def severity_label SEVERITY_LABELS.find { |range, _| range.cover?(@severity) }&.last end |
#to_h ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb', line 46 def to_h { id: @id, description: @description, domain: @domain, severity: @severity, severity_label: severity_label, options: @options, chosen_option: @chosen_option, reasoning: @reasoning, framework_used: @framework_used, resolved: @resolved, created_at: @created_at, resolved_at: @resolved_at } end |