<commit_before>require 'doing_stream/version'
require 'doing_stream/stream'
require 'doing_stream/streams'

class DoingStream::DoingStream
  attr_accessor :streams

  def initialize streams
    @streams = streams
  end

  def latest n = 5
    streams.map do |stream|
      stream.entries.take(2)
    end.flatten.sort_by(&:published).reverse.take(5)
  end

  def entries
    @entries ||= streams.map(&:entries).flatten.sort_by(&:published).reverse
  end<commit_msg>Allow specifying max number of entries to take from each stream<commit_after>require 'doing_stream/version'
require 'doing_stream/stream'
require 'doing_stream/streams'

class DoingStream::DoingStream
  attr_accessor :streams

  def initialize streams
    @streams = streams
  end

  def latest n = 5, m = 2
    streams.map do |stream|
      stream.entries.take((m.respond_to? :call) ? m.call(stream) : m)
    end.flatten.sort_by(&:published).reverse.take(n)
  end

  def entries
    @entries ||= streams.map(&:entries).flatten.sort_by(&:published).reverse
  end
{'fraction_non_alphanumeric': 0.1111111111111111, 'fraction_numerical': 0.004873294346978557, 'mean_word_length': 4.266666666666667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1505314', 'n_tokens_mistral': 346, 'n_tokens_neox': 329, 'n_words': 76}