Class: Omniboard::ProjectWrapper
- Inherits:
-
Object
- Object
- Omniboard::ProjectWrapper
- Defined in:
- lib/omniboard/project_wrapper.rb
Instance Attribute Summary collapse
-
#column ⇒ Object
Returns the value of attribute column.
-
#dimmed ⇒ Object
(also: #dimmed?)
Is this project dimmed (i.e. shown “faded out”).
-
#group ⇒ Object
Returns the value of attribute group.
-
#icon ⇒ Object
Should this project display an icon in the kanban? If so, what’s the filename of the icon?.
-
#icon_alt ⇒ Object
If this project displayed an icon, we can supply an alternate text.
-
#marked ⇒ Object
(also: #marked?)
Is this project marked to show up specially?.
-
#project ⇒ Object
Returns the value of attribute project.
Instance Method Summary collapse
-
#all_tasks_deferred? ⇒ Boolean
Are all the available tasks in this project deferred?.
-
#colour ⇒ Object
————————————— Colour methods.
-
#css_classes ⇒ Object
A list of CSS classes to apply to this project.
-
#days_until_action ⇒ Object
How many days until one of our tasks becomes available?.
- #deferred_date ⇒ Object
- #due_date ⇒ Object
-
#formatted_note ⇒ Object
Format this project’s note field to create nice html.
-
#initialize(project, column: nil) ⇒ ProjectWrapper
constructor
Create a new project wrapper, wrapping project.
- #light_colour ⇒ Object
-
#method_missing(sym, *args, &blck) ⇒ Object
————————————— Runs on method missing.
-
#num_tasks ⇒ Object
————————————— Number of tasks.
-
#task_list ⇒ Object
————————————— Turn this project’s tasks into a list.
- #to_s ⇒ Object
Constructor Details
#initialize(project, column: nil) ⇒ ProjectWrapper
Create a new project wrapper, wrapping project
21 22 23 24 25 |
# File 'lib/omniboard/project_wrapper.rb', line 21 def initialize(project, column: nil) @project = project @column = column @marked = false end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &blck) ⇒ Object
Runs on method missing. Allows project to step in and take the method if it can.
46 47 48 49 50 51 52 |
# File 'lib/omniboard/project_wrapper.rb', line 46 def method_missing(sym, *args, &blck) if @project.respond_to?(sym) @project.send(sym, *args, &blck) else raise NoMethodError, "undefined method #{sym} for #{self.inspect}" end end |
Instance Attribute Details
#column ⇒ Object
Returns the value of attribute column.
3 4 5 |
# File 'lib/omniboard/project_wrapper.rb', line 3 def column @column end |
#dimmed ⇒ Object Also known as: dimmed?
Is this project dimmed (i.e. shown “faded out”)
11 12 13 |
# File 'lib/omniboard/project_wrapper.rb', line 11 def dimmed @dimmed end |
#group ⇒ Object
Returns the value of attribute group.
4 5 6 |
# File 'lib/omniboard/project_wrapper.rb', line 4 def group @group end |
#icon ⇒ Object
Should this project display an icon in the kanban? If so, what’s the filename of the icon?
15 16 17 |
# File 'lib/omniboard/project_wrapper.rb', line 15 def icon @icon end |
#icon_alt ⇒ Object
If this project displayed an icon, we can supply an alternate text
18 19 20 |
# File 'lib/omniboard/project_wrapper.rb', line 18 def icon_alt @icon_alt end |
#marked ⇒ Object Also known as: marked?
Is this project marked to show up specially?
7 8 9 |
# File 'lib/omniboard/project_wrapper.rb', line 7 def marked @marked end |
#project ⇒ Object
Returns the value of attribute project.
2 3 4 |
# File 'lib/omniboard/project_wrapper.rb', line 2 def project @project end |
Instance Method Details
#all_tasks_deferred? ⇒ Boolean
Are all the available tasks in this project deferred?
91 92 93 |
# File 'lib/omniboard/project_wrapper.rb', line 91 def all_tasks_deferred? next_tasks.size > 0 && actionable_tasks.size == 0 end |
#colour ⇒ Object
Colour methods
29 30 31 |
# File 'lib/omniboard/project_wrapper.rb', line 29 def colour (@group || Omniboard::Group).colour end |
#css_classes ⇒ Object
A list of CSS classes to apply to this project
82 83 84 85 86 87 88 |
# File 'lib/omniboard/project_wrapper.rb', line 82 def css_classes classes = ["project", column.display] classes << "marked" if marked? classes << "dimmed" if dimmed? classes << "hidden" if dimmed? && column && column.property(:hide_dimmed) classes end |
#days_until_action ⇒ Object
How many days until one of our tasks becomes available?
96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/omniboard/project_wrapper.rb', line 96 def days_until_action earliest_start = next_tasks.map(&:start).sort.first if earliest_start.nil? 0 else earliest_start = earliest_start.to_date if earliest_start < Date.today 0 else (earliest_start - Date.today).to_i end end end |
#deferred_date ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/omniboard/project_wrapper.rb', line 65 def deferred_date if self.start self.start.strftime("%d %B %Y") else "" end end |
#due_date ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/omniboard/project_wrapper.rb', line 73 def due_date if self.due self.due.strftime("%d %B %Y") else "" end end |
#formatted_note ⇒ Object
Format this project’s note field to create nice html
61 62 63 |
# File 'lib/omniboard/project_wrapper.rb', line 61 def formatted_note @formatted_note ||= Omniboard::StyledText.parse(self.note || "").to_html end |
#light_colour ⇒ Object
33 34 35 |
# File 'lib/omniboard/project_wrapper.rb', line 33 def light_colour (@group || Omniboard::Group).light_colour end |
#num_tasks ⇒ Object
Number of tasks
39 40 41 |
# File 'lib/omniboard/project_wrapper.rb', line 39 def num_tasks @num_tasks ||= project.incomplete_tasks.count end |
#task_list ⇒ Object
Turn this project’s tasks into a list
56 57 58 |
# File 'lib/omniboard/project_wrapper.rb', line 56 def task_list tasks_to_list(@project.tasks) end |
#to_s ⇒ Object
110 111 112 |
# File 'lib/omniboard/project_wrapper.rb', line 110 def to_s self.project.to_s end |