Skip to content
This repository was archived by the owner on Oct 19, 2022. It is now read-only.

Commit 7edd54a

Browse files
committed
Merge pull request github#52 from JuanitoFatas/patch/complete-p
Predicate complete? should return boolean.
2 parents b4d746c + f59879b commit 7edd54a

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

lib/task_list.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,20 @@ def summary
2525

2626
class Item < Struct.new(:checkbox_text, :source)
2727
Complete = /\[[xX]\]/.freeze # see TaskList::Filter
28+
29+
# Public: Check if a task list is complete.
30+
#
31+
# Examples
32+
#
33+
# Item.new(checkbox_text: "- [x]").complete?
34+
# # => true
35+
#
36+
# Item.new(checkbox_text: "- [ ]").complete?
37+
# # => false
38+
#
39+
# Returns true for checked list, false otherwise
2840
def complete?
29-
checkbox_text =~ Complete
41+
!!(checkbox_text =~ Complete)
3042
end
3143
end
3244
end

0 commit comments

Comments
 (0)