Class: Nps::Survey
- Inherits:
-
Object
- Object
- Nps::Survey
- Defined in:
- lib/nps/survey.rb
Instance Attribute Summary collapse
-
#ballot ⇒ Object
readonly
Returns the value of attribute ballot.
Instance Method Summary collapse
-
#initialize ⇒ Survey
constructor
Public: Initialize a Net Promoter Score (NPS) survey.
-
#percentage_of_detractors ⇒ Object
Public: The percentage of detractor votes in the survey.
-
#percentage_of_passives ⇒ Object
Public: The percentage of passive votes in the survey.
-
#percentage_of_promoters ⇒ Object
Public: The percentage of promoter votes in the survey.
-
#score ⇒ Object
Public: The Net Promoter Score (NPS) for the survey.
-
#vote!(value, opts = {}) ⇒ Object
Public: Add a vote to the survey with the given value.
Constructor Details
#initialize ⇒ Survey
Public: Initialize a Net Promoter Score (NPS) survey
Example:
survey = Nps::Survey.new
survey.vote!(10)
survey.score
13 14 15 |
# File 'lib/nps/survey.rb', line 13 def initialize @ballot = Nps.configuration.ballot_adaptor.new end |
Instance Attribute Details
#ballot ⇒ Object (readonly)
Returns the value of attribute ballot.
4 5 6 |
# File 'lib/nps/survey.rb', line 4 def ballot @ballot end |
Instance Method Details
#percentage_of_detractors ⇒ Object
Public: The percentage of detractor votes in the survey.
33 34 35 |
# File 'lib/nps/survey.rb', line 33 def percentage_of_detractors calculator.percentage_of_detractors end |
#percentage_of_passives ⇒ Object
Public: The percentage of passive votes in the survey.
28 29 30 |
# File 'lib/nps/survey.rb', line 28 def percentage_of_passives calculator.percentage_of_passives end |
#percentage_of_promoters ⇒ Object
Public: The percentage of promoter votes in the survey.
23 24 25 |
# File 'lib/nps/survey.rb', line 23 def percentage_of_promoters calculator.percentage_of_promoters end |
#score ⇒ Object
Public: The Net Promoter Score (NPS) for the survey.
18 19 20 |
# File 'lib/nps/survey.rb', line 18 def score calculator.score end |
#vote!(value, opts = {}) ⇒ Object
Public: Add a vote to the survey with the given value
value - The value of the vote on the NPS scale (0..10) opts - A hash of meta data associated with the vote (default: {})
41 42 43 |
# File 'lib/nps/survey.rb', line 41 def vote!(value, opts = {}) ballot.vote!(value, opts) end |