Class: Nps::Survey

Inherits:
Object
  • Object
show all
Defined in:
lib/nps/survey.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSurvey

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

#ballotObject (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_detractorsObject

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_passivesObject

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_promotersObject

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

#scoreObject

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