Class: Omniboard::ProjectWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/omniboard/project_wrapper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#columnObject

Returns the value of attribute column.



3
4
5
# File 'lib/omniboard/project_wrapper.rb', line 3

def column
  @column
end

#dimmedObject 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

#groupObject

Returns the value of attribute group.



4
5
6
# File 'lib/omniboard/project_wrapper.rb', line 4

def group
  @group
end

#iconObject

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_altObject

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

#markedObject 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

#projectObject

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?

Returns:

  • (Boolean)


91
92
93
# File 'lib/omniboard/project_wrapper.rb', line 91

def all_tasks_deferred?
	next_tasks.size > 0 && actionable_tasks.size == 0
end

#colourObject


Colour methods



29
30
31
# File 'lib/omniboard/project_wrapper.rb', line 29

def colour
	(@group || Omniboard::Group).colour
end

#css_classesObject

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_actionObject

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_dateObject



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_dateObject



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_noteObject

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_colourObject



33
34
35
# File 'lib/omniboard/project_wrapper.rb', line 33

def light_colour
	(@group || Omniboard::Group).light_colour
end

#num_tasksObject


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_listObject


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_sObject



110
111
112
# File 'lib/omniboard/project_wrapper.rb', line 110

def to_s
	self.project.to_s
end