Class: Reader::Host
- Inherits:
-
Object
- Object
- Reader::Host
- Includes:
- Renderer
- Defined in:
- lib/city_watch/reader/server.rb
Instance Method Summary collapse
- #current_raw ⇒ Object
- #data_sets ⇒ Object
- #data_sets_key ⇒ Object
- #hostname ⇒ Object
-
#initialize(host) ⇒ Host
constructor
A new instance of Host.
- #key(more) ⇒ Object
- #key_prefix ⇒ Object
- #raw_key ⇒ Object
- #raws(num = 1) ⇒ Object
- #summaries(num = 1) ⇒ Object
- #summary ⇒ Object
- #summary_html ⇒ Object
- #summary_key ⇒ Object
- #watchmen ⇒ Object
- #watchmen_key ⇒ Object
Methods included from Renderer
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_raw ⇒ Object
55 56 57 |
# File 'lib/city_watch/reader/server.rb', line 55 def current_raw raws.first end |
#data_sets ⇒ Object
31 32 33 |
# File 'lib/city_watch/reader/server.rb', line 31 def data_sets CityWatch.redis.smembers(data_sets_key) end |
#data_sets_key ⇒ Object
35 36 37 |
# File 'lib/city_watch/reader/server.rb', line 35 def data_sets_key @data_sets_key ||= key(:data_sets) end |
#hostname ⇒ Object
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_prefix ⇒ Object
71 72 73 |
# File 'lib/city_watch/reader/server.rb', line 71 def key_prefix @key_prefix ||= "#{CityWatch.config[:prefix]}::#{@host}" end |
#raw_key ⇒ Object
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 |
#summary ⇒ Object
39 40 41 |
# File 'lib/city_watch/reader/server.rb', line 39 def summary summaries.first end |
#summary_html ⇒ Object
43 44 45 |
# File 'lib/city_watch/reader/server.rb', line 43 def summary_html "server/summary" end |
#summary_key ⇒ Object
51 52 53 |
# File 'lib/city_watch/reader/server.rb', line 51 def summary_key @summary_key ||= key(:summary) end |
#watchmen ⇒ Object
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_key ⇒ Object
27 28 29 |
# File 'lib/city_watch/reader/server.rb', line 27 def watchmen_key key(:watchmen) end |