Class: CML::Tags::Ratings

Inherits:
CML::Tag show all
Defined in:
lib/cml/tags/ratings.rb

Constant Summary collapse

Template =
<<-HTML.freeze
{{label}}
<table>
  <thead>
    <tr>
<th></th>
{% for rating in ratings limit:10 %}
<th>{{forloop.index}}</th>
{% endfor %}
<th></th>
    </tr>
  </thead>
  <tbody>
    <tr>
<td>{{from}}</td>
{% for rating in ratings limit:10 %}
<td>{{rating}}</td>
{% endfor %}
<td>{{to}}</td>
    </tr>
  </tbody>
</table>
HTML

Instance Attribute Summary

Attributes inherited from CML::Tag

#attrs, #cml, #tag

Instance Method Summary collapse

Methods inherited from CML::Tag

#children, #classes, #convert, #gold=, #gold?, #initialize, #instructions, #label, #legend, #name, #prefix, #raw_label, #to_html, #to_liquid, #to_s, #validate?, #validations, #value, #wrapper, #wrapper_classes

Constructor Details

This class inherits a constructor from CML::Tag

Instance Method Details

#dataObject



28
29
30
# File 'lib/cml/tags/ratings.rb', line 28

def data
  super.merge({"ratings" => ratings, "from" => @attrs["from"].to_s, "to" => @attrs["to"].to_s})
end

#ratingsObject



32
33
34
35
36
37
38
39
# File 'lib/cml/tags/ratings.rb', line 32

def ratings
  @cml.xpath("cml:rating").map do |c|
    c["name"] ||= prefix
    c["validates"] ||= @attrs["validates"]
    c["value"] ||= @attrs["label"]
    Radio.new(c).convert
  end
end