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

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.

Parameters:

  • actions (Array<String, Symbol>)

Returns:

  • (Integer)

Raises:

  • (ArgumentError)

    if actions is not an array

  • (ArgumentError)

    if action is unknown



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