Sha256: b6b0e4b1f6c4c88d3eb7ac370f313584830a9e7b36700a51bb510d72f2fd6e62
Contents?: true
Size: 1.21 KB
Versions: 22
Compression:
Stored size: 1.21 KB
Contents
module GroupDocs module Api module Helpers module ByteFlag # # Converts array of values to byte flag using hash of value => byte. # # @param [Array<String, Symbol>] values # @param [Hash] value_byte_hash # @return [Integer] # @raise [ArgumentError] if values is not an array # @api private # def byte_from_array(values, value_byte_hash) flag = 0 values.each do |value| flag += value_byte_hash[value] end flag end # # Converts byte flag to array of values using hash of value => byte. # # @param [Integer] byte # @param [Hash] value_byte_hash # @return [Integer] # @api private # 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 end # ByteFlag end # Helpers end # Api end # GroupDocs
Version data entries
22 entries across 22 versions & 1 rubygems