Method: Platform::ActionViewExtension::InstanceMethods#platform_rating_tag

Defined in:
lib/platform/extensions/action_view_extension.rb

#platform_rating_tag(rating, opts = {}) ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/platform/extensions/action_view_extension.rb', line 93

def platform_rating_tag(rating, opts = {})
  return "" unless rating

  value = rating.value || 0
  style = []
  style << "width:#{opts[:width]}" if opts[:width]

  html = "<span dir='ltr'>"
  1.upto(5) do |i|
    if i <= value  
      html << image_tag("platform/rating_star1.png", :style => style.join(";"))
    else
      html << image_tag("platform/rating_star0.png", :style => style.join(";"))
    end 
  end
  html << "</span>"
  html.html_safe
end