Created
January 31, 2014 01:32
-
-
Save medhiwidjaja/8725038 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (c) 2012 Medhi Widjaja | |
module AnalysisMethods | |
module Ahp | |
module PairwiseComparable | |
class PairwiseComparison | |
include Mongoid::Document | |
field :id1, type: Moped::BSON::ObjectId | |
field :id2, type: Moped::BSON::ObjectId | |
field :value, type: Float | |
embedded_in :pairwise_comparable | |
def slider_value | |
self.value | |
end | |
def comparison_value | |
self.value > 0 ? 1/(value+1) : -value+1 | |
end | |
def convert | |
v = self.value.to_r | |
w = v >= 1 ? -v+1 : v.denominator-1 | |
w.to_f | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment