Class: Shellfish::ProblemLoader
- Inherits:
-
Object
- Object
- Shellfish::ProblemLoader
- Defined in:
- lib/shellfish/problem_loader.rb
Instance Method Summary collapse
Instance Method Details
#load(file) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/shellfish/problem_loader.rb', line 6 def load(file) f = open(file) result = f.read f.close load_from_string(result) end |
#load_from_string(input) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/shellfish/problem_loader.rb', line 13 def load_from_string(input) dsl, data = input.split("__END__\n") script = <<-EOS Shellfish::ProblemDsl.new(Shellfish::Problem.new) { #{dsl} }.problem EOS problem = eval script, TOPLEVEL_BINDING problem.expected_result = data if data problem end |