class Elefant::Web
Public Instance Methods
css_for(field)
click to toggle source
# File lib/elefant/web.rb, line 46 def css_for(field) I18n.t(field, scope: "css", default: "") end
current_path()
click to toggle source
# File lib/elefant/web.rb, line 65 def current_path @current_path ||= request.path_info.gsub(/^\//,'') end
get_stats(name, params = [])
click to toggle source
# File lib/elefant/web.rb, line 42 def get_stats(name, params = []) stats.get(name, params) end
link(name, target, params = {})
click to toggle source
# File lib/elefant/web.rb, line 55 def link(name, target, params = {}) extra = params.any? ? "?" + params.map {|k, v| "#{k}=#{v}" }.join("&") : "" css = target == current_path ? 'active' : '' %Q{<a href="#{root_path}#{target}#{extra}" class="#{css}">#{name}</a>} end
root_path()
click to toggle source
# File lib/elefant/web.rb, line 61 def root_path %Q{#{env['SCRIPT_NAME']}/} end
stats()
click to toggle source
# File lib/elefant/web.rb, line 38 def stats @stats ||= Elefant::Stats.new end
t(*args, options)
click to toggle source
# File lib/elefant/web.rb, line 50 def t(*args, options) options.merge!(locale: :en) I18n.t(*args, options) end