Class: Reader::Host

Inherits:
Object
  • Object
show all
Includes:
Renderer
Defined in:
lib/city_watch/reader/server.rb

Instance Method Summary collapse

Methods included from Renderer

#render, #render_bare

Constructor Details

#initialize(host) ⇒ Host

Returns a new instance of Host.



13
14
15
# File 'lib/city_watch/reader/server.rb', line 13

def initialize(host)
	@host = host
end

Instance Method Details

#current_rawObject



55
56
57
# File 'lib/city_watch/reader/server.rb', line 55

def current_raw
	raws.first
end

#data_setsObject



31
32
33
# File 'lib/city_watch/reader/server.rb', line 31

def data_sets
	CityWatch.redis.smembers(data_sets_key)
end

#data_sets_keyObject



35
36
37
# File 'lib/city_watch/reader/server.rb', line 35

def data_sets_key
	@data_sets_key ||= key(:data_sets)
end

#hostnameObject



17
18
19
# File 'lib/city_watch/reader/server.rb', line 17

def hostname
	@host
end

#key(more) ⇒ Object



67
68
69
# File 'lib/city_watch/reader/server.rb', line 67

def key(more)
	"#{key_prefix}::#{more}"
end

#key_prefixObject



71
72
73
# File 'lib/city_watch/reader/server.rb', line 71

def key_prefix
	@key_prefix ||= "#{CityWatch.config[:prefix]}::#{@host}"
end

#raw_keyObject



63
64
65
# File 'lib/city_watch/reader/server.rb', line 63

def raw_key
	@raw_key ||= key(:raw_stats)
end

#raws(num = 1) ⇒ Object



59
60
61
# File 'lib/city_watch/reader/server.rb', line 59

def raws(num=1)
	CityWatch.redis.zrevrange(raw_key,0,num)
end

#summaries(num = 1) ⇒ Object



47
48
49
# File 'lib/city_watch/reader/server.rb', line 47

def summaries(num=1)
	CityWatch.redis.zrevrange(summary_key,0,num).map {|sum| Yajl::Parser.parse(sum) }
end

#summaryObject



39
40
41
# File 'lib/city_watch/reader/server.rb', line 39

def summary
	summaries.first
end

#summary_htmlObject



43
44
45
# File 'lib/city_watch/reader/server.rb', line 43

def summary_html
	render_bare "server/summary"
end

#summary_keyObject



51
52
53
# File 'lib/city_watch/reader/server.rb', line 51

def summary_key
	@summary_key ||= key(:summary)
end

#watchmenObject



21
22
23
24
25
# File 'lib/city_watch/reader/server.rb', line 21

def watchmen
	CityWatch.redis.smembers(watchmen_key).map do |name|
		Reader::Watchman.new(name)
	end
end

#watchmen_keyObject



27
28
29
# File 'lib/city_watch/reader/server.rb', line 27

def watchmen_key
	key(:watchmen)
end