Class: ProblemLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/asker/loader/problem_loader.rb

Instance Method Summary collapse

Constructor Details

#initialize(lang, context) ⇒ ProblemLoader

Returns a new instance of ProblemLoader.



8
9
10
11
# File 'lib/asker/loader/problem_loader.rb', line 8

def initialize(lang, context)
  @lang = lang
  @context = context
end

Instance Method Details

#call(xmldata, filepath) ⇒ Object

Load XML data about Problem object

Parameters:

  • xmldata (XML Object)
  • filepath (String)

Returns:

  • Problem object



18
19
20
21
22
23
24
# File 'lib/asker/loader/problem_loader.rb', line 18

def call(xmldata, filepath)
  data = read_problemdata_from_xml(xmldata, File.basename(filepath))
  problem = Problem.from(data)
  problem.lang = @lang
  problem.context = @context
  problem
end