Sha256: 168a1bef2ee27a4cbf374eff428101200aad6f0afbf3331e46bfd6ecf1b121af

Contents?: true

Size: 747 Bytes

Versions: 1

Compression:

Stored size: 747 Bytes

Contents

module Aai
  module Utils
    # Raises SystemExit if one of the fnames does not exist.
    def check_files fnames
      fnames.each do |fname|
        AbortIf.abort_unless_file_exists fname
      end
    end

    def two_ary_permutations a1, a2
      permutations = []

      a1.each do |elem1|
        a2.each do |elem2|
          permutations << [elem1, elem2] << [elem2, elem1]
        end
      end

      permutations
    end

    def one_way_combinations a1, a2, no_duplicates=true
      permutations = []

      a1.each do |elem1|
        a2.each do |elem2|
          if !no_duplicates || (no_duplicates && elem1 != elem2)
            permutations << [elem1, elem2]
          end
        end
      end

      permutations
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aai-0.1.0 lib/aai/utils.rb