Class: StableMatching::Marriage::Validator
- Defined in:
- lib/stable-matching/marriage/validator.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(preference_table, partner_table) ⇒ Validator
constructor
A new instance of Validator.
- #validate! ⇒ Object
Methods inherited from Validator
Constructor Details
#initialize(preference_table, partner_table) ⇒ Validator
Returns a new instance of Validator.
16 17 18 19 |
# File 'lib/stable-matching/marriage/validator.rb', line 16 def initialize(preference_table, partner_table) @preference_table = preference_table @partner_table = partner_table end |
Class Method Details
.validate_pair!(alpha_preferences, beta_preferences) ⇒ Object
11 12 13 14 |
# File 'lib/stable-matching/marriage/validator.rb', line 11 def self.validate_pair!(alpha_preferences, beta_preferences) new(alpha_preferences, beta_preferences).validate! new(beta_preferences, alpha_preferences).validate! end |
Instance Method Details
#validate! ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/stable-matching/marriage/validator.rb', line 21 def validate! case when !hash_of_arrays? then handle_not_hash_of_arrays when empty? then handle_empty when !strings_or_integers? then handle_not_strings_or_integers when !symmetrical? then handle_not_symmetrical end raise ::StableMatching::InvalidPreferences, @error if @error end |