Sha256: 01c026eb974c6c25d0acd71658000fc1155bcc1ae7ec8fc79623b37a67339c63

Contents?: true

Size: 733 Bytes

Versions: 2

Compression:

Stored size: 733 Bytes

Contents

# frozen_string_literal: true

module ArticleFixtureGen
  module Data
    # Wraps attributes for a single marker-tag pair instance. Initially, the
    # only attribute supported is `:id_string`.
    class SmtpAttributes
      include Enumerable

      def initialize(config:)
        text = config.smtp_text
        @items = Array.new(config.smtp_count) { build_item(text) }
        self
      end

      def each(&_block)
        @items.each { |item| yield item }
      end

      private

      attr_reader :items

      def build_item(text, rand_limit: 10_000)
        id_num = rand(rand_limit) + 1
        Struct.new(:id_string).new "#{text}-#{id_num}"
      end
    end # class ArticleFixtureGen::Data::SmtpAttributes
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
article_fixture_gen-0.1.2 lib/article_fixture_gen/data/smtp_attributes.rb
article_fixture_gen-0.1.1 lib/article_fixture_gen/data/smtp_attributes.rb