Class: TaskList::Summary

Inherits:
Struct
  • Object
show all
Defined in:
lib/task_list/summary.rb

Overview

Provides a summary of provided TaskList ‘items`.

‘items` is an Array of TaskList::Item objects.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#itemsObject

Returns the value of attribute items

Returns:

  • (Object)

    the current value of items



9
10
11
# File 'lib/task_list/summary.rb', line 9

def items
  @items
end

Instance Method Details

#complete_countObject

Public: returns the number of complete TaskList::Item objects.



21
22
23
# File 'lib/task_list/summary.rb', line 21

def complete_count
  items.select{ |i| i.complete? }.size
end

#incomplete_countObject

Public: returns the number of incomplete TaskList::Item objects.



26
27
28
# File 'lib/task_list/summary.rb', line 26

def incomplete_count
  items.select{ |i| !i.complete? }.size
end

#item_countObject

Public: returns the number of TaskList::Item objects.



16
17
18
# File 'lib/task_list/summary.rb', line 16

def item_count
  items.size
end

#items?Boolean

Public: returns true if there are any TaskList::Item objects.

Returns:

  • (Boolean)


11
12
13
# File 'lib/task_list/summary.rb', line 11

def items?
  item_count > 0
end