Sha256: ede00abd5158b283c1773d8282669c7f3d7975ae6fa1dc0d3407e5eac6d229c6

Contents?: true

Size: 450 Bytes

Versions: 1

Compression:

Stored size: 450 Bytes

Contents

module MaNameGenerator
  class Base
    MA_NAMES = File.read("#{File.expand_path(__dir__)}/data/names", mode: 'r:UTF-8').split("\n")

    class << self
      def generate
        MA_NAMES.sample
      end

      def generate_unique(excluding:)
        raise NotArray unless excluding.is_a?(Array)

        excluded_items(excluding).sample
      end

      private

      def excluded_items(items)
        MA_NAMES - items
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ma_name_generator-0.1.0 lib/ma_name_generator/base.rb