Class: TasksCLI::Task
- Inherits:
-
Object
- Object
- TasksCLI::Task
- Defined in:
- lib/tasks_cli/task.rb
Instance Attribute Summary collapse
-
#blocked_by ⇒ Object
readonly
Returns the value of attribute blocked_by.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#epic ⇒ Object
readonly
Returns the value of attribute epic.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
-
#relates_to ⇒ Object
readonly
Returns the value of attribute relates_to.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
Instance Method Summary collapse
- #detailed_view ⇒ Object
- #extract_value(field) ⇒ Object
-
#initialize(row) ⇒ Task
constructor
A new instance of Task.
- #matches?(field, value) ⇒ Boolean
- #priority_colored ⇒ Object
- #status_color ⇒ Object
- #to_csv ⇒ Object
- #to_s ⇒ Object
- #update_timestamp ⇒ Object
Constructor Details
#initialize(row) ⇒ Task
Returns a new instance of Task.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/tasks_cli/task.rb', line 9 def initialize(row) @epic = extract_value(row[0]) @number = extract_value(row[1]) @name = extract_value(row[2]) @description = extract_value(row[3]) @priority = extract_value(row[4]) @status = extract_value(row[5]) @relates_to = extract_value(row[6]) @blocked_by = extract_value(row[7]) @updated_at = extract_value(row[8]) || Time.now.iso8601 end |
Instance Attribute Details
#blocked_by ⇒ Object (readonly)
Returns the value of attribute blocked_by.
7 8 9 |
# File 'lib/tasks_cli/task.rb', line 7 def blocked_by @blocked_by end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
7 8 9 |
# File 'lib/tasks_cli/task.rb', line 7 def description @description end |
#epic ⇒ Object (readonly)
Returns the value of attribute epic.
7 8 9 |
# File 'lib/tasks_cli/task.rb', line 7 def epic @epic end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/tasks_cli/task.rb', line 7 def name @name end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
7 8 9 |
# File 'lib/tasks_cli/task.rb', line 7 def number @number end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
7 8 9 |
# File 'lib/tasks_cli/task.rb', line 7 def priority @priority end |
#relates_to ⇒ Object (readonly)
Returns the value of attribute relates_to.
7 8 9 |
# File 'lib/tasks_cli/task.rb', line 7 def relates_to @relates_to end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
7 8 9 |
# File 'lib/tasks_cli/task.rb', line 7 def status @status end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
7 8 9 |
# File 'lib/tasks_cli/task.rb', line 7 def updated_at @updated_at end |
Instance Method Details
#detailed_view ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/tasks_cli/task.rb', line 32 def detailed_view <<~TASK #{Rainbow('Epic:').bright} #{@epic} #{Rainbow('Number:').bright} #{Rainbow(@number).cyan} #{Rainbow('Name:').bright} #{Rainbow(@name).bright} #{Rainbow('Description:').bright} #{@description} #{Rainbow('Priority:').bright} #{priority_colored} #{Rainbow('Status:').bright} #{status_color} #{Rainbow('Relates To:').bright} #{@relates_to} #{Rainbow('Blocked By:').bright} #{@blocked_by} #{Rainbow('Last Updated:').bright} #{@updated_at} TASK end |
#extract_value(field) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/tasks_cli/task.rb', line 21 def extract_value(field) return '' if field.nil? return field if field.is_a?(String) field.is_a?(Array) ? field[1].to_s.strip : field.to_s.strip end |
#matches?(field, value) ⇒ Boolean
50 51 52 53 54 |
# File 'lib/tasks_cli/task.rb', line 50 def matches?(field, value) send(field.to_sym).to_s.downcase.include?(value.to_s.downcase) rescue NoMethodError false end |
#priority_colored ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'lib/tasks_cli/task.rb', line 69 def priority_colored case @priority.downcase when 'high' then Rainbow(@priority).red when 'medium' then Rainbow(@priority).yellow when 'low' then Rainbow(@priority).green else Rainbow(@priority).white end end |
#status_color ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/tasks_cli/task.rb', line 60 def status_color case @status.downcase when 'to do' then Rainbow(@status).red when 'in progress' then Rainbow(@status).yellow when 'done' then Rainbow(@status).green else Rainbow(@status).white end end |
#to_csv ⇒ Object
46 47 48 |
# File 'lib/tasks_cli/task.rb', line 46 def to_csv [@epic, @number, @name, @description, @priority, @status, @relates_to, @blocked_by, @updated_at] end |
#to_s ⇒ Object
28 29 30 |
# File 'lib/tasks_cli/task.rb', line 28 def to_s "#{Rainbow(@number).cyan}: #{Rainbow(@name).bright} (#{status_color}) - Priority: #{priority_colored} - Updated: #{@updated_at}" end |
#update_timestamp ⇒ Object
56 57 58 |
# File 'lib/tasks_cli/task.rb', line 56 def @updated_at = Time.now.iso8601 end |