Sha256: 1ef5e63a3d47b0c7220380d89ff4aa02934b5948a79d363ff935ebe7519a6af7

Contents?: true

Size: 453 Bytes

Versions: 1

Compression:

Stored size: 453 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.1 lib/ma_name_generator/base.rb