class Dalli::Ui::StatsPresenter
Attributes
dalli[RW]
Public Class Methods
new(dalli_stats, template)
click to toggle source
# File lib/dalli/ui/stats_presenter.rb, line 9 def initialize(dalli_stats, template) @dalli = Hashie::Mash.new(dalli_stats) @template = template end
Public Instance Methods
cache_size()
click to toggle source
# File lib/dalli/ui/stats_presenter.rb, line 21 def cache_size h.number_to_human_size(dalli.limit_maxbytes) end
chart_data()
click to toggle source
# File lib/dalli/ui/stats_presenter.rb, line 29 def chart_data [ { value: 100 - hit_rate, count: dalli.get_misses, color: "#F7464A", highlight: "#FF5A5E", label: "Miss rate" }, { value: hit_rate, count: dalli.get_hits, color: "#46BFBD", highlight: "#5AD3D1", label: "Hit rate" } ] end
hit_rate()
click to toggle source
# File lib/dalli/ui/stats_presenter.rb, line 14 def hit_rate hit_rate = 0 total = Integer(dalli.get_hits) + Integer(dalli.get_misses) hit_rate = Integer(dalli.get_hits).to_f / total.to_f * 100 if total > 0 hit_rate.round end
host_id(host)
click to toggle source
# File lib/dalli/ui/stats_presenter.rb, line 25 def host_id(host) Digest::SHA1.hexdigest host end
Private Instance Methods
h()
click to toggle source
# File lib/dalli/ui/stats_presenter.rb, line 50 def h @template end