Class: Poptart::SurveyQuestion
Instance Attribute Summary collapse
-
#answer ⇒ Object
Returns the value of attribute answer.
-
#key ⇒ Object
Returns the value of attribute key.
-
#responses ⇒ Object
Returns the value of attribute responses.
-
#text ⇒ Object
Returns the value of attribute text.
-
#type ⇒ Object
Returns the value of attribute type.
Attributes inherited from Model
Instance Method Summary collapse
- #boolean? ⇒ Boolean
- #created_at ⇒ Object
- #freeform? ⇒ Boolean
-
#initialize(response) ⇒ SurveyQuestion
constructor
A new instance of SurveyQuestion.
- #multiple? ⇒ Boolean
- #range? ⇒ Boolean
- #submit ⇒ Object
- #time? ⇒ Boolean
Methods included from Request
connection, get, post, put
Methods inherited from Model
#questions_url, root, #survey_questions_url, #surveys_url, #users_url
Constructor Details
#initialize(response) ⇒ SurveyQuestion
Returns a new instance of SurveyQuestion.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/poptart/survey_question.rb', line 8 def initialize(response) super @text = params['text'] @type = params['type'] @freeform = params['freeform'] @responses = params['responses'] @answer = params['answer'] @created_at = params['created_at'] @key = params['key'] if @answer == 't' @answer = true elsif @answer == 'f' @answer = false end end |
Instance Attribute Details
#answer ⇒ Object
Returns the value of attribute answer.
6 7 8 |
# File 'lib/poptart/survey_question.rb', line 6 def answer @answer end |
#key ⇒ Object
Returns the value of attribute key.
6 7 8 |
# File 'lib/poptart/survey_question.rb', line 6 def key @key end |
#responses ⇒ Object
Returns the value of attribute responses.
6 7 8 |
# File 'lib/poptart/survey_question.rb', line 6 def responses @responses end |
#text ⇒ Object
Returns the value of attribute text.
6 7 8 |
# File 'lib/poptart/survey_question.rb', line 6 def text @text end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/poptart/survey_question.rb', line 6 def type @type end |
Instance Method Details
#boolean? ⇒ Boolean
25 26 27 |
# File 'lib/poptart/survey_question.rb', line 25 def boolean? type == "boolean" end |
#created_at ⇒ Object
45 46 47 |
# File 'lib/poptart/survey_question.rb', line 45 def created_at DateTime.parse(@created_at) end |
#freeform? ⇒ Boolean
41 42 43 |
# File 'lib/poptart/survey_question.rb', line 41 def freeform? @freeform == true end |
#multiple? ⇒ Boolean
29 30 31 |
# File 'lib/poptart/survey_question.rb', line 29 def multiple? type == "multiple" end |
#range? ⇒ Boolean
33 34 35 |
# File 'lib/poptart/survey_question.rb', line 33 def range? type == "range" end |
#submit ⇒ Object
49 50 51 52 |
# File 'lib/poptart/survey_question.rb', line 49 def submit response = put(links.put.href, { id: id, survey_question: { answer: answer} }) response.status == 204 end |
#time? ⇒ Boolean
37 38 39 |
# File 'lib/poptart/survey_question.rb', line 37 def time? type == "time" end |