Class: PnoteClient::Documents::Pnote::Problem
- Inherits:
-
Object
- Object
- PnoteClient::Documents::Pnote::Problem
- Includes:
- Utils::StringUtil
- Defined in:
- lib/pnote_client/documents/pnote/problem.rb
Overview
연습문제(Exercise)와 실전문제(Practice)의 부모 클래스중복되는 부분을 재사용하기위해 만듦
Instance Attribute Summary collapse
-
#explaination ⇒ Object
Returns the value of attribute explaination.
-
#question ⇒ Object
Returns the value of attribute question.
Instance Method Summary collapse
- #add_answer_line(new_line) ⇒ Object
- #add_choice_line(new_line) ⇒ Object
- #add_explaination_line(new_line) ⇒ Object
- #add_question_line(new_line) ⇒ Object
- #answer ⇒ Object
- #choices ⇒ Object
-
#initialize ⇒ Problem
constructor
A new instance of Problem.
Methods included from Utils::StringUtil
Constructor Details
#initialize ⇒ Problem
Returns a new instance of Problem.
13 14 15 16 17 18 |
# File 'lib/pnote_client/documents/pnote/problem.rb', line 13 def initialize @question = nil @answer = nil @explaination = nil @choice = nil end |
Instance Attribute Details
#explaination ⇒ Object
Returns the value of attribute explaination.
11 12 13 |
# File 'lib/pnote_client/documents/pnote/problem.rb', line 11 def explaination @explaination end |
#question ⇒ Object
Returns the value of attribute question.
11 12 13 |
# File 'lib/pnote_client/documents/pnote/problem.rb', line 11 def question @question end |
Instance Method Details
#add_answer_line(new_line) ⇒ Object
24 25 26 |
# File 'lib/pnote_client/documents/pnote/problem.rb', line 24 def add_answer_line(new_line) @answer = add_line(@answer, new_line) end |
#add_choice_line(new_line) ⇒ Object
32 33 34 |
# File 'lib/pnote_client/documents/pnote/problem.rb', line 32 def add_choice_line(new_line) @choice = add_line(@choice, new_line) end |
#add_explaination_line(new_line) ⇒ Object
28 29 30 |
# File 'lib/pnote_client/documents/pnote/problem.rb', line 28 def add_explaination_line(new_line) @explaination = add_line(@explaination, new_line) end |
#add_question_line(new_line) ⇒ Object
20 21 22 |
# File 'lib/pnote_client/documents/pnote/problem.rb', line 20 def add_question_line(new_line) @question = add_line(@question, new_line) end |
#answer ⇒ Object
36 37 38 39 |
# File 'lib/pnote_client/documents/pnote/problem.rb', line 36 def answer return nil if @answer.nil? return @answer.match(/\s*\[정답\]\s*(.*)/).to_a[1].strip end |
#choices ⇒ Object
41 42 43 44 45 46 |
# File 'lib/pnote_client/documents/pnote/problem.rb', line 41 def choices return [] if @choice.nil? choice_number_pattern = /①|②|③|④|⑤/ return @choice.split(choice_number_pattern).reject {|el| el.empty?}.map {|el| el.strip} end |