Class: GithubToCanvasQuiz::Model::Answer::Matching

Inherits:
Object
  • Object
show all
Defined in:
lib/github_to_canvas_quiz/model/answer/matching.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Matching

Returns a new instance of Matching.



9
10
11
12
13
# File 'lib/github_to_canvas_quiz/model/answer/matching.rb', line 9

def initialize(options)
  options.each do |key, value|
    send("#{key}=", value) if respond_to?("#{key}=")
  end
end

Instance Attribute Details

#commentsObject

Returns the value of attribute comments.



7
8
9
# File 'lib/github_to_canvas_quiz/model/answer/matching.rb', line 7

def comments
  @comments
end

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/github_to_canvas_quiz/model/answer/matching.rb', line 7

def id
  @id
end

#leftObject

Returns the value of attribute left.



7
8
9
# File 'lib/github_to_canvas_quiz/model/answer/matching.rb', line 7

def left
  @left
end

#rightObject

Returns the value of attribute right.



7
8
9
# File 'lib/github_to_canvas_quiz/model/answer/matching.rb', line 7

def right
  @right
end

#textObject

Returns the value of attribute text.



7
8
9
# File 'lib/github_to_canvas_quiz/model/answer/matching.rb', line 7

def text
  @text
end

#titleObject

Returns the value of attribute title.



7
8
9
# File 'lib/github_to_canvas_quiz/model/answer/matching.rb', line 7

def title
  @title
end

Instance Method Details

#to_hObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/github_to_canvas_quiz/model/answer/matching.rb', line 23

def to_h
  {
    'answer_text' => left,
    'answer_weight' => 100,
    'answer_comment_html' => comments,
    'answer_match_left' => left,
    'answer_match_right' => right,
    'id' => id
  }.reject { |_,v| v.nil? }
end

#to_markdownObject



15
16
17
18
19
20
21
# File 'lib/github_to_canvas_quiz/model/answer/matching.rb', line 15

def to_markdown
  MarkdownBuilder.build do |md|
    md.h2(title)
    md.ul(left, right)
    md.blockquote(md.html_to_markdown(comments)) unless comments.empty?
  end
end