Class: Woro::TaskList
- Inherits:
-
Object
- Object
- Woro::TaskList
- Defined in:
- lib/woro/task_list.rb
Overview
Generates the list of all tasks for printout to console.
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#list ⇒ Object
readonly
Returns the value of attribute list.
Class Method Summary collapse
-
.extract_description(task_content) ⇒ Object
Extract description from gist’s data content string.
Instance Method Summary collapse
-
#fill ⇒ Object
Fill task list by loading tasks from the configured adapters and locally.
-
#initialize(config) ⇒ TaskList
constructor
A new instance of TaskList.
-
#print ⇒ Object
Print the current task list to console.
-
#width ⇒ integer
Determine the max count of characters for all task names.
Constructor Details
#initialize(config) ⇒ TaskList
Returns a new instance of TaskList.
10 11 12 13 |
# File 'lib/woro/task_list.rb', line 10 def initialize(config) @config = config @list = [] end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/woro/task_list.rb', line 8 def config @config end |
#list ⇒ Object (readonly)
Returns the value of attribute list.
8 9 10 |
# File 'lib/woro/task_list.rb', line 8 def list @list end |
Class Method Details
.extract_description(task_content) ⇒ Object
Extract description from gist’s data content string.
- String
-
description string
39 40 41 42 43 |
# File 'lib/woro/task_list.rb', line 39 def self.extract_description(task_content) # regex from http://stackoverflow.com/questions/171480/regex-grabbing-values-between-quotation-marks match = task_content.match(/desc (["'])((?:(?!\1)[^\\]|(?:\\\\)*\\[^\\])*)\1/) match && match[2] || 'No description' end |
Instance Method Details
#fill ⇒ Object
Fill task list by loading tasks from the configured adapters and locally.
23 24 25 26 27 |
# File 'lib/woro/task_list.rb', line 23 def fill fill_list_from_adapters fill_list_from_local self end |
#print ⇒ Object
Print the current task list to console.
30 31 32 33 34 |
# File 'lib/woro/task_list.rb', line 30 def print list.each do |entry| entry.headline ? print_headline(entry) : print_task_description(entry) end end |
#width ⇒ integer
Determine the max count of characters for all task names.
17 18 19 |
# File 'lib/woro/task_list.rb', line 17 def width @width ||= list.map { |t| t.name_with_args ? t.name_with_args.length : 0 }.max || 10 end |