Module: NumRu::NetCDFDeferred

Defined in:
lib/numru/gphys/varraynetcdf.rb

Overview

class NetCDFVar

Instance Method Summary collapse

Instance Method Details

#add_deferred(proc, args, length) ⇒ Object

To be “extend”ed in a NetCDF object to add simgular methods to support deferred operations. Used together with NetCDFVarDeferred.



26
27
28
29
30
# File 'lib/numru/gphys/varraynetcdf.rb', line 26

def add_deferred(proc,args,length)
	 defined?(@len_stored) ? @len_stored+=length : @len_stored=length
	 @deferred = Array.new if ! defined?(@deferred) || ! @deferred
	 @deferred.push( [proc, args] ) 
end

#closeObject



57
58
59
60
# File 'lib/numru/gphys/varraynetcdf.rb', line 57

def close
	 enddef rescue nil
	 super
end

#enddefObject



44
45
46
47
# File 'lib/numru/gphys/varraynetcdf.rb', line 44

def enddef
	 super
	 flush
end

#flushObject



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/numru/gphys/varraynetcdf.rb', line 31

def flush
	 if @deferred
	    @deferred.each{|opr|
  if ($DEBUG)
		  print "## flushing ## "; p opr
         end
  opr[0].call(opr[1])
	    }
	    @deferred = nil
	    NetCDFVarDeferred.flushed_length(@len_stored)
	    @len_stored = 0
	 end
end

#syncObject



48
49
50
51
52
53
54
55
56
# File 'lib/numru/gphys/varraynetcdf.rb', line 48

def sync
	 if define_mode?
	    enddef
	    super
	    redef
	 else
	    super
	 end
end