Class: Fairy::PInputFile

Inherits:
PSingleExportInput show all
Defined in:
lib/fairy/node/p-input-file.rb

Constant Summary

Constants included from PSingleExportable

Fairy::PSingleExportable::END_OF_STREAM, Fairy::PSingleExportable::ST_EXPORT_FINISH, Fairy::PSingleExportable::ST_WAIT_EXPORT_FINISH

Constants inherited from PIOFilter

Fairy::PIOFilter::ST_WAIT_IMPORT

Constants inherited from PFilter

Fairy::PFilter::END_OF_STREAM, Fairy::PFilter::ST_ACTIVATE, Fairy::PFilter::ST_FINISH, Fairy::PFilter::ST_INIT

Instance Attribute Summary

Attributes included from PSingleExportable

#export

Attributes inherited from PFilter

#IGNORE_EXCEPTION, #id, #log_id, #ntask

Class Method Summary collapse

Instance Method Summary collapse

Methods included from PSingleExportable

#start, #start_export, #terminate, #wait_export_finish

Methods inherited from PIOFilter

#input=

Methods inherited from PFilter

#abort_running, #basic_start, #break_running, #each, #global_break, #global_break_from_other, #handle_exception, #key, #key=, #next, #no, #no=, #notice_status, #processor, #start, #start_export, #start_watch_status, #status=, #terminate, #terminate_proc

Constructor Details

#initialize(id, ntask, bjob, opts = nil) ⇒ PInputFile

Returns a new instance of PInputFile.



20
21
22
23
# File 'lib/fairy/node/p-input-file.rb', line 20

def initialize(id, ntask, bjob, opts=nil)
  super
  @file = nil
end

Class Method Details

.open(processor, bjob, opts, fn) ⇒ Object



15
16
17
18
# File 'lib/fairy/node/p-input-file.rb', line 15

def PInputFile.open(processor, bjob, opts, fn)
  nfile = PInputFile.new(processor, bjob, opts)
  nfile.open(fn)
end

Instance Method Details

#basic_each(&block) ⇒ Object

def start

super do

for l in @file @export.push l end @file.close @file = nil # FileオブジェクトをGCの対象にするため

  end
end


87
88
89
90
91
92
93
94
# File 'lib/fairy/node/p-input-file.rb', line 87

def basic_each(&block)
  begin
	@file.each &block
  ensure
	@file.close
	@file = nil # FileオブジェクトをGCの対象にするため
  end
end

#basic_nextObject



96
97
98
99
100
101
102
103
104
105
106
# File 'lib/fairy/node/p-input-file.rb', line 96

def basic_next
  begin
	ret = @file.gets
  ensure
	unless ret
	  @file.close
	  @file = nil
	  return :END_OF_STREAM 
	end
  end
end

#open(nfileplace) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/fairy/node/p-input-file.rb', line 25

def open(nfileplace)
  @file_name = nfileplace.path
  self.no = nfileplace.no
  begin
	@file = File.open(@file_name)
  rescue 
	e = $!.exception($!.message+ "(vfile entry##{nfileplace.no}: #{nfileplace.url})")
	e.set_backtrace($!.backtrace)

	Log::error_exception(e)
	handle_exception(e)
	raise e
  end
#      start
  self
end