Class: GuardianSearcher::Helpers::Generator
- Inherits:
-
Object
- Object
- GuardianSearcher::Helpers::Generator
- Defined in:
- lib/guardian_searcher/helpers/generator.rb
Overview
The class helps generating an array of object from the passed parameters It can be used to generate e.g. an array of Content objects, each one initialised with the data of a single results Hash coming from the Guardian API response
Instance Method Summary collapse
Instance Method Details
#generate(results, klass) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/guardian_searcher/helpers/generator.rb', line 10 def generate(results, klass) content = [] results.each do |result| content << Object.const_get(klass).new(result) end content end |