Sha256: af2d0fb9fb111de19bd93f5db86425f7c87f577a0089cce763c466437f4d5efe

Contents?: true

Size: 857 Bytes

Versions: 4

Compression:

Stored size: 857 Bytes

Contents

# frozen_string_literal: true

require 'html/pipeline'

module HTML
  class Pipeline
    class TaskList
      # Provides a summary of provided TaskList `items`.
      #
      # `items` is an Array of TaskList::Item objects.
      Summary = Struct.new(:items) do
        # Public: returns true if there are any TaskList::Item objects.
        def items?
          item_count.positive?
        end

        # Public: returns the number of TaskList::Item objects.
        def item_count
          items.size
        end

        # Public: returns the number of complete TaskList::Item objects.
        def complete_count
          items.select(&:complete?).size
        end

        # Public: returns the number of incomplete TaskList::Item objects.
        def incomplete_count
          items.reject(&:complete?).size
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
html-pipeline-task_list-0.1.0 lib/html/pipeline/task_list/summary.rb
html-pipeline-task_list-0.0.3 lib/html/pipeline/task_list/summary.rb
html-pipeline-task_list-0.0.2 lib/html/pipeline/task_list/summary.rb
html-pipeline-task_list-0.0.1 lib/html/pipeline/task_list/summary.rb