Class: XmlFilesDatasource
- Inherits:
-
Object
- Object
- XmlFilesDatasource
- Includes:
- Enumerable
- Defined in:
- lib/rotating_es_loader/xml_files_datasource.rb
Overview
:nodoc
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(glob) ⇒ XmlFilesDatasource
constructor
A new instance of XmlFilesDatasource.
- #normalize(o) ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(glob) ⇒ XmlFilesDatasource
Returns a new instance of XmlFilesDatasource.
9 10 11 |
# File 'lib/rotating_es_loader/xml_files_datasource.rb', line 9 def initialize(glob) @files = Dir.glob(glob).to_a end |
Instance Method Details
#each(&block) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rotating_es_loader/xml_files_datasource.rb', line 17 def each(&block) return to_enum(:each) unless block @files.each do |xml_file| hash = XmlSimple.xml_in( xml_file, ForceArray: false, SuppressEmpty: '' ) Array(normalize(hash)).each(&block) end self end |
#normalize(o) ⇒ Object
13 14 15 |
# File 'lib/rotating_es_loader/xml_files_datasource.rb', line 13 def normalize(o) o end |
#size ⇒ Object
32 33 34 |
# File 'lib/rotating_es_loader/xml_files_datasource.rb', line 32 def size @files.size end |