Class: GithubToCanvasQuiz::Model::Answer::MultipleAnswers
- Inherits:
-
Object
- Object
- GithubToCanvasQuiz::Model::Answer::MultipleAnswers
- Defined in:
- lib/github_to_canvas_quiz/model/answer/multiple_answers.rb
Instance Attribute Summary collapse
-
#comments ⇒ Object
Returns the value of attribute comments.
-
#id ⇒ Object
Returns the value of attribute id.
-
#text ⇒ Object
Returns the value of attribute text.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(options) ⇒ MultipleAnswers
constructor
A new instance of MultipleAnswers.
- #to_h ⇒ Object
- #to_markdown ⇒ Object
Constructor Details
#initialize(options) ⇒ MultipleAnswers
Returns a new instance of MultipleAnswers.
9 10 11 12 13 |
# File 'lib/github_to_canvas_quiz/model/answer/multiple_answers.rb', line 9 def initialize() .each do |key, value| send("#{key}=", value) if respond_to?("#{key}=") end end |
Instance Attribute Details
#comments ⇒ Object
Returns the value of attribute comments.
7 8 9 |
# File 'lib/github_to_canvas_quiz/model/answer/multiple_answers.rb', line 7 def comments @comments end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/github_to_canvas_quiz/model/answer/multiple_answers.rb', line 7 def id @id end |
#text ⇒ Object
Returns the value of attribute text.
7 8 9 |
# File 'lib/github_to_canvas_quiz/model/answer/multiple_answers.rb', line 7 def text @text end |
#title ⇒ Object
Returns the value of attribute title.
7 8 9 |
# File 'lib/github_to_canvas_quiz/model/answer/multiple_answers.rb', line 7 def title @title end |
Instance Method Details
#to_h ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/github_to_canvas_quiz/model/answer/multiple_answers.rb', line 23 def to_h { 'answer_html' => text, 'answer_weight' => title == 'Correct' ? 100 : 0, 'answer_comment_html' => comments, 'id' => id }.reject { |_,v| v.nil? } end |
#to_markdown ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/github_to_canvas_quiz/model/answer/multiple_answers.rb', line 15 def to_markdown MarkdownBuilder.build do |md| md.h2(title) md.md(md.html_to_markdown(text)) md.blockquote(md.html_to_markdown(comments)) unless comments.empty? end end |