Exception: Syskit::AmbiguousSpecialization
Overview
Exception raised by CompositionModel#instanciate when multiple specializations can be applied
Instance Attribute Summary collapse
-
#candidates ⇒ Object
readonly
The set of possible specializations given the model and the selection.
-
#composition_model ⇒ Object
readonly
The composition model that was being instanciated.
-
#selection ⇒ {String=>Model}
readonly
The specialization selector.
Instance Method Summary collapse
-
#initialize(composition_model, selection, candidates) ⇒ AmbiguousSpecialization
constructor
A new instance of AmbiguousSpecialization.
- #pretty_print(pp) ⇒ Object
Constructor Details
#initialize(composition_model, selection, candidates) ⇒ AmbiguousSpecialization
Returns a new instance of AmbiguousSpecialization
741 742 743 744 |
# File 'lib/syskit/exceptions.rb', line 741 def initialize(composition_model, selection, candidates) @composition_model, @selection, @candidates = composition_model, selection, candidates end |
Instance Attribute Details
#candidates ⇒ Object (readonly)
The set of possible specializations given the model and the selection. This
is a list of [merged, set] tuples where set
is a set of
specializations and merged
the complete specialization model
739 740 741 |
# File 'lib/syskit/exceptions.rb', line 739 def candidates @candidates end |
#composition_model ⇒ Object (readonly)
The composition model that was being instanciated
732 733 734 |
# File 'lib/syskit/exceptions.rb', line 732 def composition_model @composition_model end |
#selection ⇒ {String=>Model} (readonly)
Returns the specialization selector
734 735 736 |
# File 'lib/syskit/exceptions.rb', line 734 def selection @selection end |
Instance Method Details
#pretty_print(pp) ⇒ Object
746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 |
# File 'lib/syskit/exceptions.rb', line 746 def pretty_print(pp) pp.text "there is an ambiguity in the instanciation of #{composition_model.short_name}" pp.breakable if selection.empty? pp.text "with no selection applied" else pp.text "with the following selection:" pp.nest(2) do pp.breakable pp.seplist(selection) do |keyvalue| key, value = *keyvalue if key.respond_to?(:short_name) key = key.short_name end value = value.each_required_model value = value.map do |v| if v.respond_to?(:short_name) then v.short_name else v.to_s end end pp.text "#{key} => #{value.join(",")}" end end end pp.breakable pp.text "the following specializations apply:" pp.nest(2) do pp.breakable pp.seplist(candidates) do |spec| pp.text spec[0].short_name end end end |