Class: AnswerFactory::Machines::SampleAnyOne

Inherits:
Machine
  • Object
show all
Defined in:
lib/machines/any_one.rb

Instance Attribute Summary

Attributes inherited from Machine

#options

Instance Method Summary collapse

Methods inherited from Machine

#initialize

Constructor Details

This class inherits a constructor from AnswerFactory::Machines::Machine

Instance Method Details

#screen(batch) ⇒ Object Also known as: generate

Raises:

  • (ArgumentError)


9
10
11
12
13
14
# File 'lib/machines/any_one.rb', line 9

def screen(batch)
  raise ArgumentError, "SampleAnyOne#screen: argument is not a Batch" unless
    batch.kind_of?(Batch)
  one = batch.sample
  return one.nil? ? Batch.new : Batch.[](one)
end