Class: LibStorj::Ext::Storj::File

Inherits:
FFI::Struct
  • Object
show all
Extended by:
FFI::Library
Defined in:
lib/ruby-libstorj/ext/file.rb,
lib/ruby-libstorj/ext/types.rb

Constant Summary collapse

PROGRESS_CALLBACK =

typedef void (*storj_progress_cb)(double progress

uint64_t bytes,
uint64_t total_bytes,
void *handle);
callback i[double uint64 uint64 pointer], :void
FINISHED_DOWNLOAD_CALLBACK =

typedef void (*storj_finished_download_cb)(int status, FILE *fd, void *handle);

callback i[int pointer pointer], :void
FINISHED_UPLOAD_CALLBACK =

typedef void (*storj_finished_upload_cb)(int error_status, char *file_id, void *handle);

callback i[int string pointer], :void

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ File

Returns a new instance of File.



22
23
24
25
26
# File 'lib/ruby-libstorj/ext/file.rb', line 22

def initialize(*args)
  super(*args)

  @name, @id, @size = self.values_at i[filename id size]
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/ruby-libstorj/ext/file.rb', line 8

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/ruby-libstorj/ext/file.rb', line 8

def name
  @name
end

#sizeObject (readonly)

Returns the value of attribute size.



8
9
10
# File 'lib/ruby-libstorj/ext/file.rb', line 8

def size
  @size
end

Class Method Details

.pointer_to_array(pointer, array_length) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/ruby-libstorj/ext/file.rb', line 28

def self.pointer_to_array(pointer, array_length)
  if pointer.nil? || pointer == FFI::MemoryPointer::NULL || array_length < 1
    return nil
  end

  ### #=> [#<LibStorj::Ext::Storj::Bucket ...>, ...]
  (0..(array_length - 1)).map do |i|
    File.new pointer[i * size]
  end
end