Skip to content

Instantly share code, notes, and snippets.

@medhiwidjaja
Created January 31, 2014 01:32
Show Gist options
  • Save medhiwidjaja/8725038 to your computer and use it in GitHub Desktop.
Save medhiwidjaja/8725038 to your computer and use it in GitHub Desktop.
# 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