Sha256: ba5047495cbcc34c5afc27b2adb2c2f1dd6bb4a7074f38c057fa00360905c5d3

Contents?: true

Size: 659 Bytes

Versions: 1

Compression:

Stored size: 659 Bytes

Contents

class Answer
    attr_accessor :kind, :order, :answer
    
      # order:  the position of the answer in the question
      # kind:   either :right or :wrong
      # answer: the text of the answer (for instance "1492")
      def initialize(order, kind, answer)
        @kind, @order, @answer = kind, order, answer
      end
    
      def to_s
        "#{@order}. #{answer}"
      end
    
      # decides if this is a right answer
      def is_right?
        @kind == Quiz::RIGHT
      end
    
      # Answer objects must be sorted according to their position
      # inside the question
      def <=>(other)
        self.order <=> other.order
      end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
estefania_exam-0.0.2 lib/quiz/answer.rb