class SimpleFeed::Providers::Redis::Stats
Attributes
boot_info[RW]
redis[RW]
Public Class Methods
destringify(hash)
click to toggle source
Converts strings values of a hash into floats or integers, if the string matches a corresponding pattern.
# File lib/simplefeed/providers/redis/stats.rb, line 32 def destringify(hash) db_hash = {} hash.each_pair do |key, value| if key =~ /^db\d+$/ h = {} value.split(/,/).each do |word| *words = word.split(/=/) h[words[0]] = words[1] end destringify(h) db_hash[key.gsub(/^db/, '').to_i] = h hash.delete(key) else hash[key] = if value =~ /^-?\d+$/ value.to_i elsif value =~ /^-?\d*\.\d+$/ value.to_f else value end end end hash[:dbstats] = db_hash unless db_hash.empty? Hashie::Mash.new(hash) end
load_boot_stats!()
click to toggle source
# File lib/simplefeed/providers/redis/stats.rb, line 59 def load_boot_stats! @boot_info ||= destringify(YAML.load(File.open(File.expand_path('boot_info.yml', __dir__)))) end
new(redis)
click to toggle source
# File lib/simplefeed/providers/redis/stats.rb, line 13 def initialize(redis) self.redis = redis end
Public Instance Methods
boot_info()
click to toggle source
# File lib/simplefeed/providers/redis/stats.rb, line 21 def boot_info self.class.boot_info end
info()
click to toggle source
# File lib/simplefeed/providers/redis/stats.rb, line 17 def info self.class.destringify(redis.info) end