Class: Gipper::Answer
- Inherits:
-
Object
- Object
- Gipper::Answer
- Includes:
- SpecialCharacterHandler, Oniguruma
- Defined in:
- lib/answer.rb
Overview
Gipper::Answer
Represents the single correct answer if there is only one answer, or one of the answer choices if multiple are provided for a question.
To populate the answer from a string use the parse method
answer = Gipper::Answer.new
answer.parse "= foo #bar"
answer.correct
>> true
answer.text
>> foo
answer.comment
>> bar
or
answer.parse "F"
answer.correct
>> false
Instance Attribute Summary collapse
-
#comment ⇒ Object
readonly
Returns the value of attribute comment.
-
#correct ⇒ Object
readonly
Returns the value of attribute correct.
-
#range ⇒ Object
readonly
Returns the value of attribute range.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#weight ⇒ Object
readonly
Returns the value of attribute weight.
Instance Method Summary collapse
-
#parse(answer, style_hint = nil) ⇒ Object
Will parse a single answer into it’s parts.
Instance Attribute Details
#comment ⇒ Object (readonly)
Returns the value of attribute comment.
33 34 35 |
# File 'lib/answer.rb', line 33 def comment @comment end |
#correct ⇒ Object (readonly)
Returns the value of attribute correct.
33 34 35 |
# File 'lib/answer.rb', line 33 def correct @correct end |
#range ⇒ Object (readonly)
Returns the value of attribute range.
33 34 35 |
# File 'lib/answer.rb', line 33 def range @range end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
33 34 35 |
# File 'lib/answer.rb', line 33 def text @text end |
#weight ⇒ Object (readonly)
Returns the value of attribute weight.
33 34 35 |
# File 'lib/answer.rb', line 33 def weight @weight end |
Instance Method Details
#parse(answer, style_hint = nil) ⇒ Object
Will parse a single answer into it’s parts. If the answer type is numerical, pass :numerical as the optional second parameter.
37 38 39 40 41 42 43 |
# File 'lib/answer.rb', line 37 def parse answer, style_hint = nil if style_hint == :numerical parse_as_numerical answer else parse_standard answer end end |