Class: Phronomy::Agent::ContextSelectionUnit
- Inherits:
-
Data
- Object
- Data
- Phronomy::Agent::ContextSelectionUnit
- Defined in:
- lib/phronomy/agent/context_selection_unit.rb
Instance Attribute Summary collapse
-
#candidate_ids ⇒ Object
readonly
Returns the value of attribute candidate_ids.
-
#dependency_unit_ids ⇒ Object
readonly
Returns the value of attribute dependency_unit_ids.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
-
#requirement ⇒ Object
readonly
Returns the value of attribute requirement.
-
#sequence_range ⇒ Object
readonly
Returns the value of attribute sequence_range.
-
#unit_id ⇒ Object
readonly
Returns the value of attribute unit_id.
Instance Method Summary collapse
-
#initialize(**values) ⇒ ContextSelectionUnit
constructor
A new instance of ContextSelectionUnit.
Constructor Details
#initialize(**values) ⇒ ContextSelectionUnit
Returns a new instance of ContextSelectionUnit.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/phronomy/agent/context_selection_unit.rb', line 15 def initialize(**values) normalized = values.merge( unit_id: values.fetch(:unit_id).to_s.freeze, candidate_ids: Array(values[:candidate_ids]).map(&:to_s).freeze, dependency_unit_ids: Array(values[:dependency_unit_ids]).map(&:to_s).freeze, kind: values.fetch(:kind).to_sym, requirement: (values[:requirement] || :optional).to_sym, priority: Integer(values[:priority] || 0), sequence_range: Array(values[:sequence_range]).map { |v| Integer(v) }.freeze, metadata: Immutable.copy(values[:metadata] || {}) ) unless %i[protocol_required declared_required optional].include?(normalized[:requirement]) raise ArgumentError, "unknown ContextSelectionUnit requirement: #{normalized[:requirement].inspect}" end unless normalized[:sequence_range].length == 2 raise ArgumentError, "ContextSelectionUnit sequence_range must contain two integers" end super(**normalized) freeze end |
Instance Attribute Details
#candidate_ids ⇒ Object (readonly)
Returns the value of attribute candidate_ids
5 6 7 |
# File 'lib/phronomy/agent/context_selection_unit.rb', line 5 def candidate_ids @candidate_ids end |
#dependency_unit_ids ⇒ Object (readonly)
Returns the value of attribute dependency_unit_ids
5 6 7 |
# File 'lib/phronomy/agent/context_selection_unit.rb', line 5 def dependency_unit_ids @dependency_unit_ids end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind
5 6 7 |
# File 'lib/phronomy/agent/context_selection_unit.rb', line 5 def kind @kind end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata
5 6 7 |
# File 'lib/phronomy/agent/context_selection_unit.rb', line 5 def @metadata end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority
5 6 7 |
# File 'lib/phronomy/agent/context_selection_unit.rb', line 5 def priority @priority end |
#requirement ⇒ Object (readonly)
Returns the value of attribute requirement
5 6 7 |
# File 'lib/phronomy/agent/context_selection_unit.rb', line 5 def requirement @requirement end |
#sequence_range ⇒ Object (readonly)
Returns the value of attribute sequence_range
5 6 7 |
# File 'lib/phronomy/agent/context_selection_unit.rb', line 5 def sequence_range @sequence_range end |
#unit_id ⇒ Object (readonly)
Returns the value of attribute unit_id
5 6 7 |
# File 'lib/phronomy/agent/context_selection_unit.rb', line 5 def unit_id @unit_id end |