Class: Tanker::SharingOptions

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/tanker/sharing_options.rb

Overview

Options that can be given when sharing data

Instance Method Summary collapse

Constructor Details

#initialize(share_with_users: [], share_with_groups: []) ⇒ SharingOptions

Returns a new instance of SharingOptions.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/tanker/sharing_options.rb', line 9

def initialize(share_with_users: [], share_with_groups: [])
  super()

  @users_objs = share_with_users.map { |id| CTanker.new_cstring id }
  users = FFI::MemoryPointer.new(:pointer, share_with_users.length)
  users.write_array_of_pointer(@users_objs)

  @groups_objs = share_with_groups.map { |id| CTanker.new_cstring id }
  groups = FFI::MemoryPointer.new(:pointer, share_with_groups.length)
  groups.write_array_of_pointer(@groups_objs)

  self[:version] = 1
  self[:recipient_public_identities] = users
  self[:nb_recipient_public_identities] = share_with_users.length
  self[:recipient_group_ids] = groups
  self[:nb_recipient_group_ids] = share_with_groups.length
end