Module: GroupDocs::Api::Helpers::ByteFlag
- Included in:
- AccessRights, Job
- Defined in:
- lib/groupdocs/api/helpers/byte_flag_helper.rb
Instance Method Summary collapse
-
#array_from_byte(byte, value_byte_hash) ⇒ Integer
private
Converts byte flag to array of values using hash of value => byte.
-
#byte_from_array(values, value_byte_hash) ⇒ Integer
private
Converts array of values to byte flag using hash of value => byte.
Instance Method Details
#array_from_byte(byte, value_byte_hash) ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Converts byte flag to array of values using hash of value => byte.
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/groupdocs/api/helpers/byte_flag_helper.rb', line 32 def array_from_byte(byte, value_byte_hash) values = [] value_byte_hash.sort { |a, b| b[1] <=> a[1] }.each do |value_byte| decreased_byte = byte - value_byte[1] if decreased_byte >= 0 values << value_byte[0] byte = decreased_byte end end values end |
#byte_from_array(values, value_byte_hash) ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Converts array of values to byte flag using hash of value => byte.
15 16 17 18 19 20 21 22 |
# File 'lib/groupdocs/api/helpers/byte_flag_helper.rb', line 15 def byte_from_array(values, value_byte_hash) flag = 0 values.each do |value| flag += value_byte_hash[value] end flag end |