Class: Rasam::PairRank
- Inherits:
-
Object
- Object
- Rasam::PairRank
- Defined in:
- lib/rasam.rb
Instance Attribute Summary collapse
-
#decisions ⇒ Object
readonly
Returns the value of attribute decisions.
Instance Method Summary collapse
- #break_tie(pair, choice, criteria) ⇒ Object
- #combination ⇒ Object
- #combinations ⇒ Object
-
#initialize(options) ⇒ PairRank
constructor
A new instance of PairRank.
- #make_rational_choice(pair, choice, criteria) ⇒ Object
- #score_for(choice) ⇒ Object
- #tied_pair ⇒ Object
Constructor Details
#initialize(options) ⇒ PairRank
Returns a new instance of PairRank.
37 38 39 40 41 42 |
# File 'lib/rasam.rb', line 37 def initialize() @options = @decisions = [] @votes = Hash.new(0) @combination = Combination.new(@options) end |
Instance Attribute Details
#decisions ⇒ Object (readonly)
Returns the value of attribute decisions.
35 36 37 |
# File 'lib/rasam.rb', line 35 def decisions @decisions end |
Instance Method Details
#break_tie(pair, choice, criteria) ⇒ Object
62 63 64 |
# File 'lib/rasam.rb', line 62 def break_tie(pair, choice, criteria) make_rational_choice(pair, choice, criteria) end |
#combination ⇒ Object
48 49 50 |
# File 'lib/rasam.rb', line 48 def combination @combination.pair end |
#combinations ⇒ Object
44 45 46 |
# File 'lib/rasam.rb', line 44 def combinations @options.combination(2).to_a end |
#make_rational_choice(pair, choice, criteria) ⇒ Object
66 67 68 69 |
# File 'lib/rasam.rb', line 66 def make_rational_choice(pair, choice, criteria) rc = RationalChoice.new(pair, choice, criteria) make(rc) end |
#score_for(choice) ⇒ Object
52 53 54 |
# File 'lib/rasam.rb', line 52 def score_for(choice) @votes[choice] end |
#tied_pair ⇒ Object
56 57 58 59 60 |
# File 'lib/rasam.rb', line 56 def tied_pair return [] if zeros? find_tie end |