Class: Pione::Agent::DirInputGeneratorMethod

Inherits:
InputGeneratorMethod show all
Defined in:
lib/pione/agent/input-generator.rb

Overview

DirGeneratorMethod is a directory based generator.

Instance Attribute Summary

Attributes inherited from InputGeneratorMethod

#input_location, #stream

Instance Method Summary collapse

Methods inherited from InputGeneratorMethod

method_name, #now

Constructor Details

#initialize(space, input_location, stream) ⇒ DirInputGeneratorMethod

Returns a new instance of DirInputGeneratorMethod.



138
139
140
141
# File 'lib/pione/agent/input-generator.rb', line 138

def initialize(space, input_location, stream)
  super
  @table ||= Hash.new
end

Instance Method Details

#generateObject



154
155
156
157
158
159
160
# File 'lib/pione/agent/input-generator.rb', line 154

def generate
  location = @enum.next
  if new_file?(location.basename, location.mtime)
    @table[location.basename] = location.mtime
    return TupleSpace::DataTuple.new(InputGenerator::DOMAIN, location.basename, location, location.mtime)
  end
end

#initObject



143
144
145
146
147
148
149
150
151
152
# File 'lib/pione/agent/input-generator.rb', line 143

def init
  # save entries as Enumerator
  if input_location
    # files in the directory
    @enum = input_location.file_entries.to_enum
  else
    # no files
    @enum = [].to_enum
  end
end