Class: Scruber::Core::Extensions::Loop
- Inherits:
-
Base
- Object
- Base
- Scruber::Core::Extensions::Loop
show all
- Defined in:
- lib/scruber/core/extensions/loop.rb
Defined Under Namespace
Modules: CoreMethods
Class Method Summary
collapse
Methods inherited from Base
descendants, inherited, register
Class Method Details
._registered_dictionaries ⇒ Object
31
32
33
|
# File 'lib/scruber/core/extensions/loop.rb', line 31
def _registered_dictionaries
@registered_dictionaries ||= {}
end
|
.add_dictionary(name, file_path, file_type) ⇒ Object
24
25
26
27
28
29
|
# File 'lib/scruber/core/extensions/loop.rb', line 24
def add_dictionary(name, file_path, file_type)
_registered_dictionaries[name.to_sym] = {
file_path: file_path,
file_type: file_type
}
end
|
.loop(dictionary, options = {}) ⇒ Object
14
15
16
17
18
19
20
21
22
|
# File 'lib/scruber/core/extensions/loop.rb', line 14
def loop(dictionary, options={})
if _registered_dictionaries.keys.include?(dictionary.to_sym)
Scruber::Helpers::DictionaryReader.read(_registered_dictionaries[dictionary.to_sym][:file_path], _registered_dictionaries[dictionary.to_sym][:file_type], options) do |obj|
yield obj
end
else
raise ArgumentError, "dictionary not registered, available dictionaries #{_registered_dictionaries.keys.inspect}"
end
end
|