Class: Log

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/models/log.rb,
lib/app/models/log.rb

Overview

Logs

Instance Method Summary collapse

Instance Method Details

#activateObject



28
29
30
31
# File 'lib/models/log.rb', line 28

def activate
	self.active = true
	self.save
end

#deactivateObject



33
34
35
36
# File 'lib/models/log.rb', line 33

def deactivate
	self.active = false
	self.save
end

#tag(tags) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/models/log.rb', line 16

def tag(tags)
	tags.split(',').each do |t|
		self.tags << Tag.where(tag: t).first_or_create
	end

	return self
end

#tagged(tag) ⇒ Object



24
25
26
# File 'lib/models/log.rb', line 24

def tagged(tag)

end

#totalObject



38
39
40
41
42
43
44
45
46
# File 'lib/models/log.rb', line 38

def total
	difference = 0
	self.series.each do |s|
		ending = s.end || Time.now
		# next unless s.start and s.end
		difference = difference + s.start.difference(ending)
	end
	difference
end