Class: JSONRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/ruql/renderers/json_renderer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(quiz, options = {}) ⇒ JSONRenderer

Returns a new instance of JSONRenderer.



6
7
8
9
10
# File 'lib/ruql/renderers/json_renderer.rb', line 6

def initialize(quiz,options={})
  @output = ''
  @json_array = []
  @quiz = quiz
end

Instance Attribute Details

#outputObject (readonly)

Returns the value of attribute output.



4
5
6
# File 'lib/ruql/renderers/json_renderer.rb', line 4

def output
  @output
end

Instance Method Details

#render_quizObject



12
13
14
# File 'lib/ruql/renderers/json_renderer.rb', line 12

def render_quiz
  @output = @quiz.questions.map {|question| JSON.pretty_generate(question.to_JSON)}
end