Class: QuestionproRails::Question
- Inherits:
 - 
      Object
      
        
- Object
 - QuestionproRails::Question
 
 
- Defined in:
 - lib/questionpro_rails/question.rb
 
Instance Attribute Summary collapse
- 
  
    
      #id  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute id.
 - 
  
    
      #order_number  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute order_number.
 - 
  
    
      #qp_answers  ⇒ Array<Hash> 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Choices available for the question.
 - 
  
    
      #text  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute text.
 
Instance Method Summary collapse
- 
  
    
      #choices  ⇒ Array<QuestionproRails::Choice> 
    
    
  
  
  
  
  
  
  
  
  
    
Extract the choices from the hashes stored inside qp_answers attribute.
 - 
  
    
      #initialize(attributes)  ⇒ Question 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Question.
 
Constructor Details
#initialize(attributes) ⇒ Question
Returns a new instance of Question.
      11 12 13 14 15 16  | 
    
      # File 'lib/questionpro_rails/question.rb', line 11 def initialize (attributes) @id = attributes['id'] @order_number = attributes['orderNumber'] @text = attributes['text'] @qp_answers = attributes['answers'] end  | 
  
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
      6 7 8  | 
    
      # File 'lib/questionpro_rails/question.rb', line 6 def id @id end  | 
  
#order_number ⇒ Object (readonly)
Returns the value of attribute order_number.
      6 7 8  | 
    
      # File 'lib/questionpro_rails/question.rb', line 6 def order_number @order_number end  | 
  
#qp_answers ⇒ Array<Hash> (readonly)
Returns Choices available for the question.
      9 10 11  | 
    
      # File 'lib/questionpro_rails/question.rb', line 9 def qp_answers @qp_answers end  | 
  
#text ⇒ Object (readonly)
Returns the value of attribute text.
      6 7 8  | 
    
      # File 'lib/questionpro_rails/question.rb', line 6 def text @text end  | 
  
Instance Method Details
#choices ⇒ Array<QuestionproRails::Choice>
Extract the choices from the hashes stored inside qp_answers attribute.
      22 23 24 25 26 27 28 29 30 31 32  | 
    
      # File 'lib/questionpro_rails/question.rb', line 22 def choices extracted_choices = [] unless self.qp_answers.nil? self.qp_answers.each do |choice| extracted_choices.push(Choice.new(choice)) end end return extracted_choices end  |