Class: Git::Heatmap::Period

Inherits:
Object
  • Object
show all
Defined in:
lib/git/heatmap/period.rb

Direct Known Subclasses

Daily, Hourly, Monthly, Quarterly, Weekly, Yearly

Instance Method Summary collapse

Instance Method Details

#aggregate(values, options = {}) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/git/heatmap/period.rb', line 24

def aggregate(values, options = {})
	slots = {}

	values.each do |value|
		time = value[:date]

		k = key(time)

		slots[k] ||= []
		slots[k] << value
	end
	
	return slots
end

#between(first, last) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/git/heatmap/period.rb', line 39

def between(first, last)
	return to_enum(:between, first, last) unless block_given?
	
	current = first
	offset = 0
	
	while true
		current = key(first, offset)
		
		if current <= last
			yield current
		else
			break
		end
		
		offset += 1
	end
end

#key(t) ⇒ Object

Raises:

  • (ArgumentError)


58
59
60
# File 'lib/git/heatmap/period.rb', line 58

def key(t)
	raise ArgumentError
end

#mktime(year, month = 1, day = 1, hour = 0, minute = 0, second = 0) ⇒ Object



62
63
64
# File 'lib/git/heatmap/period.rb', line 62

def mktime(year, month=1, day=1, hour=0, minute=0, second=0)
	return Time.gm(year, month, day, hour, minute, second)
end