Class: PnoteClient::Documents::Pnote::Problem

Inherits:
Object
  • Object
show all
Includes:
Utils::StringUtil
Defined in:
lib/pnote_client/documents/pnote/problem.rb

Overview

연습문제(Exercise)와 실전문제(Practice)의 부모 클래스중복되는 부분을 재사용하기위해 만듦

Direct Known Subclasses

Exercise, Practice

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils::StringUtil

#add_line

Constructor Details

#initializeProblem

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

#explainationObject

Returns the value of attribute explaination.



11
12
13
# File 'lib/pnote_client/documents/pnote/problem.rb', line 11

def explaination
  @explaination
end

#questionObject

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

#answerObject



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

#choicesObject



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