Class: LcpRuby::Display::Renderers::Rating

Inherits:
BaseRenderer show all
Defined in:
lib/lcp_ruby/display/renderers/rating.rb

Instance Method Summary collapse

Methods inherited from BaseRenderer

#link_producing?

Instance Method Details

#render(value, options = {}, record: nil, view_context: nil) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/lcp_ruby/display/renderers/rating.rb', line 5

def render(value, options = {}, record: nil, view_context: nil)
  max = (options["max"] || 5).to_i
  val = value.to_i.clamp(0, max)
  filled = "★" * val
  empty = "☆" * (max - val)
  view_context.(:span, (filled + empty).html_safe, class: "lcp-rating-display")
end