File: summary.rb

package info (click to toggle)
ruby-task-list 2.3.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 256 kB
  • sloc: ruby: 308; javascript: 58; sh: 14; makefile: 8
file content (30 lines) | stat: -rw-r--r-- 743 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# encoding: utf-8
require 'html/pipeline'
require 'task_list'

class TaskList
  # Provides a summary of provided TaskList `items`.
  #
  # `items` is an Array of TaskList::Item objects.
  class Summary < Struct.new(:items)
    # Public: returns true if there are any TaskList::Item objects.
    def items?
      item_count > 0
    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{ |i| i.complete? }.size
    end

    # Public: returns the number of incomplete TaskList::Item objects.
    def incomplete_count
      items.select{ |i| !i.complete? }.size
    end
  end
end