Class: Asciidoctor::Question::QuestionBlockProcessor
- Inherits:
-
Extensions::BaseProcessor
- Object
- Extensions::BlockProcessor
- Extensions::BaseProcessor
- Asciidoctor::Question::QuestionBlockProcessor
- Defined in:
- lib/asciidoctor-question/question/extension.rb
Direct Known Subclasses
Instance Method Summary collapse
- #has_solution(parent) ⇒ Object
-
#initialize(name = nil, config = {}) ⇒ QuestionBlockProcessor
constructor
A new instance of QuestionBlockProcessor.
- #process(parent, source, tag) ⇒ Object
Methods inherited from Extensions::BaseProcessor
inherited, #post_answers, #process_error, #process_error_push
Constructor Details
#initialize(name = nil, config = {}) ⇒ QuestionBlockProcessor
Returns a new instance of QuestionBlockProcessor.
12 13 14 15 |
# File 'lib/asciidoctor-question/question/extension.rb', line 12 def initialize name = nil, config = {} super name, config @id = 0 end |
Instance Method Details
#has_solution(parent) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/asciidoctor-question/question/extension.rb', line 44 def has_solution(parent) if not ( parent.document.attributes['solution'].nil? and parent.attributes['solution'].nil? ) true else if parent.parent.nil? false else has_solution(parent.parent) end end end |
#process(parent, source, tag) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/asciidoctor-question/question/extension.rb', line 17 def process(parent, source, tag) block = nil err = nil type = tag[:type] type = tag[:type] = 'mc' if type == 'mc' or type == 'multiplechoice' or type == 'multiple_choice' tag[:id] = @id = @id + 1 tag[:solution] = has_solution parent if type.nil? err = 'Typ fehlt.' end if err.nil? if type == 'mc' block = process_question_mc parent, source, tag elsif type == 'gap' block = process_question_gap parent, source, tag end else block = process_error parent, err, source.lines end block end |