Class: ExoBasic::LikertValue
- Inherits:
-
Object
- Object
- ExoBasic::LikertValue
- Defined in:
- lib/exobasic/likert_value.rb
Constant Summary collapse
- UNKNOWN =
0
- MINIMUM =
1
Instance Attribute Summary collapse
-
#maximum ⇒ Object
readonly
Returns the value of attribute maximum.
-
#v ⇒ Object
readonly
Returns the value of attribute v.
Class Method Summary collapse
Instance Method Summary collapse
- #get_extended_range ⇒ Object
- #get_range ⇒ Object
-
#initialize(v, maximum) ⇒ LikertValue
constructor
A new instance of LikertValue.
- #normalize ⇒ Object
- #normalize_known ⇒ Object
Constructor Details
#initialize(v, maximum) ⇒ LikertValue
Returns a new instance of LikertValue.
8 9 10 11 |
# File 'lib/exobasic/likert_value.rb', line 8 def initialize(v, maximum) @v = [LikertValue::UNKNOWN, [v, maximum].min].max @maximum = maximum end |
Instance Attribute Details
#maximum ⇒ Object (readonly)
Returns the value of attribute maximum.
3 4 5 |
# File 'lib/exobasic/likert_value.rb', line 3 def maximum @maximum end |
#v ⇒ Object (readonly)
Returns the value of attribute v.
3 4 5 |
# File 'lib/exobasic/likert_value.rb', line 3 def v @v end |
Class Method Details
.likert_avg(total_likert, n, maximum) ⇒ Object
37 38 39 |
# File 'lib/exobasic/likert_value.rb', line 37 def self.likert_avg(total_likert, n, maximum) LikertValue.real_to_likert(1.0 * total_likert / (1.0 * n), maximum) end |
.real_to_likert(v, maximum) ⇒ Object
33 34 35 |
# File 'lib/exobasic/likert_value.rb', line 33 def self.real_to_likert(v, maximum) LikertValue.new(v.round(), maximum).normalize_known end |
Instance Method Details
#get_extended_range ⇒ Object
17 18 19 |
# File 'lib/exobasic/likert_value.rb', line 17 def get_extended_range LikertValue::UNKNOWN..@maximum end |
#get_range ⇒ Object
13 14 15 |
# File 'lib/exobasic/likert_value.rb', line 13 def get_range LikertValue::MINIMUM..@maximum end |
#normalize ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/exobasic/likert_value.rb', line 21 def normalize if @v != LikertValue::UNKNOWN [LikertValue::MINIMUM, [@v, @maximum].min].max else LikertValue::UNKNOWN end end |
#normalize_known ⇒ Object
29 30 31 |
# File 'lib/exobasic/likert_value.rb', line 29 def normalize_known [LikertValue::MINIMUM, [@v, @maximum].min].max end |