Module: Watchmen

Defined in:
lib/city_watch/watchmen.rb

Class Method Summary collapse

Class Method Details

.dataObject



11
12
13
14
15
16
17
18
# File 'lib/city_watch/watchmen.rb', line 11

def self.data
	@watchmen.inject({}) do |acc,watchman|
		if !CityWatch.config[:watchmen] || (CityWatch.config[:watchmen].is_a?(Array) && CityWatch.config[:watchmen].include?(watchman.name.to_sym)) || (CityWatch.config[:watchmen].is_a?(Hash) && CityWatch.config[:watchmen][watchman.name.to_sym])
			acc[watchman.name] = watchman.data
		end
		acc
	end
end

.eachObject



29
30
31
32
33
# File 'lib/city_watch/watchmen.rb', line 29

def self.each
	@watchmen.each do |w|
		yield w
	end
end

.get(name) ⇒ Object



25
26
27
# File 'lib/city_watch/watchmen.rb', line 25

def self.get(name)
	@watchmen.select {|w| w.name.to_s == name.to_s }.first
end

.register(cls) ⇒ Object



20
21
22
23
# File 'lib/city_watch/watchmen.rb', line 20

def self.register(cls)
	@watchmen ||= []
	@watchmen << cls
end

.testObject



3
4
5
6
7
8
9
# File 'lib/city_watch/watchmen.rb', line 3

def self.test
	@watchmen.each do |cmd|
		puts "Running #{cmd.name}:"
		puts cmd.data
		puts "Done."
	end
end