Module: GroupDocs::Api::Helpers::Actions
- Included in:
- Job
- Defined in:
- lib/groupdocs/api/helpers/actions_helper.rb
Constant Summary collapse
- ACTIONS =
{ none: 0, convert: 1, combine: 2, compress_zip: 4, compress_rar: 8, trace: 16, convert_body: 32, bind_data: 64, print: 128, import_annotations: 256, }
Instance Method Summary collapse
-
#convert_actions_to_byte(actions) ⇒ Integer
private
Converts actions array to byte flag.
-
#convert_byte_to_actions(byte) ⇒ Array<Symbol>
private
Converts actions byte flag to array.
Instance Method Details
#convert_actions_to_byte(actions) ⇒ 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 actions array to byte flag.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/groupdocs/api/helpers/actions_helper.rb', line 28 def convert_actions_to_byte(actions) actions.is_a?(Array) or raise ArgumentError, "Actions should be an array, received: #{actions.inspect}" actions = actions.map(&:to_sym) possible_actions = ACTIONS.map { |hash| hash.first } actions.each do |action| possible_actions.include?(action) or raise ArgumentError, "Unknown action: #{action.inspect}" end flag = 0 actions.each do |action| flag += ACTIONS[action] end flag end |
#convert_byte_to_actions(byte) ⇒ Array<Symbol>
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 actions byte flag to array.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/groupdocs/api/helpers/actions_helper.rb', line 53 def convert_byte_to_actions(byte) byte.is_a?(Integer) or raise ArgumentError, "Byte flag should be an integer, received: #{byte.inspect}" actions = [] ACTIONS.reverse_each do |action, flag| decreased_byte = byte - flag if decreased_byte >= 0 actions << action byte = decreased_byte end end unless actions == [:none] actions.delete(:none) end actions end |