Class: Gloo::Objs::EachFile
- Inherits:
-
Object
- Object
- Gloo::Objs::EachFile
- Defined in:
- lib/gloo/objs/ctrl/each_file.rb
Constant Summary collapse
- FILE =
'file'.freeze
- EXT =
'ext'.freeze
- WILD =
'*'.freeze
Class Method Summary collapse
-
.use_for?(iterator_obj) ⇒ Boolean
Use this iterator for each loop?.
Instance Method Summary collapse
-
#initialize(engine, iterator_obj) ⇒ EachFile
constructor
——————————————————————— Create Iterator ———————————————————————.
-
#run ⇒ Object
Run for each file.
-
#set_file(f) ⇒ Object
Set the value of the word.
-
#wildcard ⇒ Object
Get the wildcard for the glob.
Constructor Details
#initialize(engine, iterator_obj) ⇒ EachFile
Create Iterator
20 21 22 23 |
# File 'lib/gloo/objs/ctrl/each_file.rb', line 20 def initialize( engine, iterator_obj ) @engine = engine @iterator_obj = iterator_obj end |
Class Method Details
Instance Method Details
#run ⇒ Object
Run for each file.
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/gloo/objs/ctrl/each_file.rb', line 47 def run folder = @iterator_obj.in_value return unless folder unless Dir.exist?( folder ) @engine.err "Folder does not exist: #{folder}" end Dir.glob( "#{folder}#{wildcard}" ).each do |f| set_file f @iterator_obj.run_do end end |
#set_file(f) ⇒ Object
Set the value of the word.
74 75 76 77 78 79 |
# File 'lib/gloo/objs/ctrl/each_file.rb', line 74 def set_file( f ) o = @iterator_obj.find_child FILE return unless o o.set_value f end |