Sha256: d24a4b62b12989c1f063020775c7d398a3f66899cf29cbbc31a27127b9def320
Contents?: true
Size: 1005 Bytes
Versions: 8
Compression:
Stored size: 1005 Bytes
Contents
require 'task_list/summary' require 'task_list/version' # encoding: utf-8 class TaskList attr_reader :record # `record` is the resource with the Markdown source text with task list items # following this syntax: # # - [ ] a task list item # - [ ] another item # - [x] a completed item # def initialize(record) @record = record end # Public: return the TaskList::Summary for this task list. # # Returns a TaskList::Summary. def summary @summary ||= TaskList::Summary.new(record.task_list_items) end class Item < Struct.new(:checkbox_text, :source) Complete = /\[[xX]\]/.freeze # see TaskList::Filter # Public: Check if a task list is complete. # # Examples # # Item.new(checkbox_text: "- [x]").complete? # # => true # # Item.new(checkbox_text: "- [ ]").complete? # # => false # # Returns true for checked list, false otherwise def complete? !!(checkbox_text =~ Complete) end end end
Version data entries
8 entries across 8 versions & 1 rubygems