Class: Mummy::Test
- Inherits:
-
Object
- Object
- Mummy::Test
- Defined in:
- lib/mummy/test.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(items) ⇒ Test
constructor
A new instance of Test.
- #run ⇒ Object
Constructor Details
#initialize(items) ⇒ Test
Returns a new instance of Test.
16 17 18 19 |
# File 'lib/mummy/test.rb', line 16 def initialize(items) @items = items @starred = [] end |
Class Method Details
.from_file(path) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/mummy/test.rb', line 3 def self.from_file(path) extension = File.extname(path) input = File.read(path) if parser = Mummy::Constants::Extensions::PARSERS[extension.downcase] items = parser.new(input).items new(items) else raise "The file isn't of a supported extension - the following are supported: " \ "#{Mummy::Constants::Extensions::PERMITTED.join(", ")}" end end |
Instance Method Details
#run ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/mummy/test.rb', line 21 def run items.shuffle.each_with_index do |item, index| puts "#{index + 1}/#{items.count}. #{item}" @starred.push(item) if $stdin.gets.chomp.include?("*") end run_with_starred if starred.any? end |