Class: Equalshares::Params
- Inherits:
-
Object
- Object
- Equalshares::Params
- Defined in:
- lib/equalshares/params.rb
Overview
Computation parameters. Mirrors the equalSharesParams object from js/main.js
and the allowed values wired up in js/interface/formHandler.js.
Constant Summary collapse
- TIE_BREAKING_METHODS =
%w[maxVotes minCost maxCost].freeze
- COMPLETIONS =
%w[none utilitarian add1 add1e add1u add1eu].freeze
- ADD1_OPTIONS =
%w[exhaustive integral].freeze
- COMPARISONS =
%w[none satisfaction exclusionRatio].freeze
- ACCURACIES =
%w[floats fractions].freeze
- SATISFACTIONS =
Satisfaction::NAMES
Instance Attribute Summary collapse
-
#accuracy ⇒ Object
readonly
Returns the value of attribute accuracy.
-
#add1_options ⇒ Object
readonly
Returns the value of attribute add1_options.
-
#comparison ⇒ Object
readonly
Returns the value of attribute comparison.
-
#completion ⇒ Object
readonly
Returns the value of attribute completion.
-
#increment ⇒ Object
readonly
Returns the value of attribute increment.
-
#satisfaction ⇒ Object
readonly
Returns the value of attribute satisfaction.
-
#tie_breaking ⇒ Object
readonly
Returns the value of attribute tie_breaking.
Instance Method Summary collapse
- #add1_option?(name) ⇒ Boolean
-
#initialize(tie_breaking: [], completion: "add1u", add1_options: %w[exhaustive integral],, comparison: "none", accuracy: "floats", increment: 1, satisfaction: "cost") ⇒ Params
constructor
Defaults match js/main.js:6-13.
Constructor Details
#initialize(tie_breaking: [], completion: "add1u", add1_options: %w[exhaustive integral],, comparison: "none", accuracy: "floats", increment: 1, satisfaction: "cost") ⇒ Params
Defaults match js/main.js:6-13. satisfaction selects the MES satisfaction
measure (pabutools parity); "cost" is the equalshares.net default.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/equalshares/params.rb', line 18 def initialize(tie_breaking: [], completion: "add1u", add1_options: %w[exhaustive integral], comparison: "none", accuracy: "floats", increment: 1, satisfaction: "cost") @tie_breaking = Array(tie_breaking) @completion = completion @add1_options = Array() @comparison = comparison @accuracy = accuracy @increment = increment @satisfaction = satisfaction validate! end |
Instance Attribute Details
#accuracy ⇒ Object (readonly)
Returns the value of attribute accuracy.
14 15 16 |
# File 'lib/equalshares/params.rb', line 14 def accuracy @accuracy end |
#add1_options ⇒ Object (readonly)
Returns the value of attribute add1_options.
14 15 16 |
# File 'lib/equalshares/params.rb', line 14 def @add1_options end |
#comparison ⇒ Object (readonly)
Returns the value of attribute comparison.
14 15 16 |
# File 'lib/equalshares/params.rb', line 14 def comparison @comparison end |
#completion ⇒ Object (readonly)
Returns the value of attribute completion.
14 15 16 |
# File 'lib/equalshares/params.rb', line 14 def completion @completion end |
#increment ⇒ Object (readonly)
Returns the value of attribute increment.
14 15 16 |
# File 'lib/equalshares/params.rb', line 14 def increment @increment end |
#satisfaction ⇒ Object (readonly)
Returns the value of attribute satisfaction.
14 15 16 |
# File 'lib/equalshares/params.rb', line 14 def satisfaction @satisfaction end |
#tie_breaking ⇒ Object (readonly)
Returns the value of attribute tie_breaking.
14 15 16 |
# File 'lib/equalshares/params.rb', line 14 def tie_breaking @tie_breaking end |
Instance Method Details
#add1_option?(name) ⇒ Boolean
30 31 32 |
# File 'lib/equalshares/params.rb', line 30 def add1_option?(name) @add1_options.include?(name) end |