Class | GPGME::Data |
In: |
lib/gpgme/data.rb
ext/gpgme/gpgme_n.c |
Parent: | Object |
The CTX argument can be `NULL’. In that case, `gpgme_wait’ waits
for any context to complete its operation.
BLOCK_SIZE | = | 4096 |
We implement +self.new+ instead of initialize because objects are actually instantiated through the C API with stuff like gpgme_data_new.
We try to create a {GPGME::Data} smartly depending on the object passed, and if another {GPGME::Data} object is passed, it just returns it, so when in doubt, you can always pass a {GPGME::Data} object.
@example empty
data = GPGME::Data.new data.write("stuff")
@example from a string
data = GPGME::Data.new("From a string")
@example from a file
data = GPGME::Data.new(File.open("secure.pass"))
@example from a file descriptor
data = GPGME::Data.new(0) # Standard input data = GPGME::Data.new(1) # Standard output file = File.open("secure.pass") data = GPGME::Data.new(file.fileno) # file descriptor
Sets the encoding for this buffer. Accepts only values in one of the DATA_ENCODING_* constants.
@raise [GPGME::Error::InvalidValue] if the value isn‘t accepted.
Read at most length bytes from the data object, or to the end of file if length is omitted or is nil.
@example
data = GPGME::Data.new("From a string") data.read # => "From a string"
@example
data = GPGME::Data.new("From a string") data.read(4) # => "From"
Seek to a given offset in the data object according to the value of whence.
@example going to the beginning of the buffer after writing something
data = GPGME::Data.new("Some data") data.read # => "Some data" data.read # => "" data.seek 0 data.read # => "Some data"