Module: Buby::Implants::TempFile

Defined in:
lib/buby/implants/temp_file.rb

Overview

This interface is used to hold details of a temporary file that has been created via a call to Buby#saveToTempFile.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.implant(file) ⇒ Object

Install ourselves into the current ITempFile java class

Parameters:

  • file (ITempFile)


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/buby/implants/temp_file.rb', line 20

def self.implant(file)
  unless file.implanted? || file.nil?
    pp [:implanting, file, file.class] if $DEBUG
    file.class.class_exec(file) do |file|
      a_methods = %w{
        getBuffer
      }
      a_methods.each do |meth|
        alias_method "__"+meth.to_s, meth
      end
      include Buby::Implants::TempFile
      a_methods.each do |meth|
        java_class.ruby_names_for_java_method(meth).each do |ruby_meth|
          define_method ruby_meth, Buby::Implants::TempFile.instance_method(meth)
        end
      end
      include Buby::Implants::Proxy
    end
  end
  file
end

Instance Method Details

#getBufferString

This method is used to retrieve the contents of the buffer that was

saved in the temporary file.

Returns:

  • (String)

    The contents of the buffer that was saved in the temporary file.



13
14
15
# File 'lib/buby/implants/temp_file.rb', line 13

def getBuffer
  String.from_java_bytes __getBuffer
end