Sha256: a388488bd139d8f74a19f99befe626395185b519a7ab605a223de4daa2650777

Contents?: true

Size: 506 Bytes

Versions: 4

Compression:

Stored size: 506 Bytes

Contents

module Ankh
  class Question
    OPERATIONS = [
      "+",
      "-"
    ]
    
    attr_reader :first_number, :second_number, :operation, :question, :answer
    
    def initialize
      @second_number = rand(9)
      @first_number = @second_number + rand(9)
      @operation = OPERATIONS[rand(2)]
      
      @question = "What is #{first_number} #{operation} #{second_number}?"
      @answer = @first_number.send(@operation, @second_number)
    end
    
    def self.generate
      new
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ankh-0.1.3 lib/ankh/question.rb
ankh-0.1.2 lib/ankh/question.rb
ankh-0.1.1 lib/ankh/question.rb
ankh-0.1.0 lib/ankh/question.rb