Class: Values::EmotionalRating

Inherits:
Object
  • Object
show all
Defined in:
app/models/values/emotional_rating.rb

Overview

Participants rate their emotion with an intensity

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label) ⇒ EmotionalRating

Returns a new instance of EmotionalRating.



16
17
18
# File 'app/models/values/emotional_rating.rb', line 16

def initialize(label)
  @label = label
end

Class Method Details

.from_rating(rating) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'app/models/values/emotional_rating.rb', line 5

def self.from_rating(rating)
  return "Not answered" if rating.nil?
  if rating < 5
    new("Bad")
  elsif rating == 5
    new("Neither")
  else
    new("Good")
  end
end

Instance Method Details

#to_sObject



20
21
22
# File 'app/models/values/emotional_rating.rb', line 20

def to_s
  @label.to_s
end