class Pione::Agent::DirInputGeneratorMethod
DirGeneratorMethod is a directory based generator.
Public Class Methods
new(space, input_location, stream)
click to toggle source
Calls superclass method
Pione::Agent::InputGeneratorMethod::new
# File lib/pione/agent/input-generator.rb, line 138 def initialize(space, input_location, stream) super @table ||= Hash.new end
Public Instance Methods
generate()
click to toggle source
# 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
init()
click to toggle source
# 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
Private Instance Methods
new_file?(name, mtime)
click to toggle source
Return true if it is a new file.
# File lib/pione/agent/input-generator.rb, line 165 def new_file?(name, mtime) # unknown file return true unless @table.has_key?(name) # updated file return mtime > @table[name] end