1 <?xml version="1.0" encoding="utf-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
8 <link rel="stylesheet" href="../css/reset.css" type="text/css" media="screen" />
9 <link rel="stylesheet" href="../css/main.css" type="text/css" media="screen" />
10 <link rel="stylesheet" href="../css/github.css" type="text/css" media="screen" />
11 <script src="../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
12 <script src="../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
13 <script src="../js/main.js" type="text/javascript" charset="utf-8"></script>
14 <script src="../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>
22 <span class="type">Module</span>
28 <li><a href="../files/app/roles/votes_rb.html">app/roles/votes.rb</a></li>
32 <div id="bodyContent">
49 <div class="sectiontitle">Methods</div>
58 <a href="#method-i-downvotes">downvotes</a>,
63 <a href="#method-i-downvotes_in_percent">downvotes_in_percent</a>
75 <a href="#method-i-upvotes">upvotes</a>,
80 <a href="#method-i-upvotes_in_percent">upvotes_in_percent</a>
92 <a href="#method-i-votes_count">votes_count</a>
119 <div class="sectiontitle">Instance Public methods</div>
122 <div class="title method-title" id="method-i-downvotes">
126 <a href="../classes/Votes.html#method-i-downvotes" name="method-i-downvotes" class="permalink">Link</a>
130 <div class="description">
131 <p>Return the number of -1 comments (downvotes)</p>
139 <div class="sourcecode">
141 <p class="source-link">
143 <a href="javascript:toggleSource('method-i-downvotes_source')" id="l_method-i-downvotes_source">show</a>
146 <div id="method-i-downvotes_source" class="dyn-source">
147 <pre><span class="ruby-comment"># File app/roles/votes.rb, line 16</span>
148 <span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">downvotes</span>
149 <span class="ruby-identifier">notes</span>.<span class="ruby-identifier">select</span>(&<span class="ruby-value">:downvote?</span>).<span class="ruby-identifier">size</span>
150 <span class="ruby-keyword">end</span></pre>
157 <div class="title method-title" id="method-i-downvotes_in_percent">
159 <b>downvotes_in_percent</b>()
161 <a href="../classes/Votes.html#method-i-downvotes_in_percent" name="method-i-downvotes_in_percent" class="permalink">Link</a>
165 <div class="description">
174 <div class="sourcecode">
176 <p class="source-link">
178 <a href="javascript:toggleSource('method-i-downvotes_in_percent_source')" id="l_method-i-downvotes_in_percent_source">show</a>
181 <div id="method-i-downvotes_in_percent_source" class="dyn-source">
182 <pre><span class="ruby-comment"># File app/roles/votes.rb, line 20</span>
183 <span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">downvotes_in_percent</span>
184 <span class="ruby-keyword">if</span> <span class="ruby-identifier">votes_count</span>.<span class="ruby-identifier">zero?</span>
185 <span class="ruby-number">0</span>
186 <span class="ruby-keyword">else</span>
187 <span class="ruby-number">100.0</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">upvotes_in_percent</span>
188 <span class="ruby-keyword">end</span>
189 <span class="ruby-keyword">end</span></pre>
196 <div class="title method-title" id="method-i-upvotes">
200 <a href="../classes/Votes.html#method-i-upvotes" name="method-i-upvotes" class="permalink">Link</a>
204 <div class="description">
205 <p>Return the number of +1 comments (upvotes)</p>
213 <div class="sourcecode">
215 <p class="source-link">
217 <a href="javascript:toggleSource('method-i-upvotes_source')" id="l_method-i-upvotes_source">show</a>
220 <div id="method-i-upvotes_source" class="dyn-source">
221 <pre><span class="ruby-comment"># File app/roles/votes.rb, line 3</span>
222 <span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">upvotes</span>
223 <span class="ruby-identifier">notes</span>.<span class="ruby-identifier">select</span>(&<span class="ruby-value">:upvote?</span>).<span class="ruby-identifier">size</span>
224 <span class="ruby-keyword">end</span></pre>
231 <div class="title method-title" id="method-i-upvotes_in_percent">
233 <b>upvotes_in_percent</b>()
235 <a href="../classes/Votes.html#method-i-upvotes_in_percent" name="method-i-upvotes_in_percent" class="permalink">Link</a>
239 <div class="description">
248 <div class="sourcecode">
250 <p class="source-link">
252 <a href="javascript:toggleSource('method-i-upvotes_in_percent_source')" id="l_method-i-upvotes_in_percent_source">show</a>
255 <div id="method-i-upvotes_in_percent_source" class="dyn-source">
256 <pre><span class="ruby-comment"># File app/roles/votes.rb, line 7</span>
257 <span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">upvotes_in_percent</span>
258 <span class="ruby-keyword">if</span> <span class="ruby-identifier">votes_count</span>.<span class="ruby-identifier">zero?</span>
259 <span class="ruby-number">0</span>
260 <span class="ruby-keyword">else</span>
261 <span class="ruby-number">100.0</span> <span class="ruby-operator">/</span> <span class="ruby-identifier">votes_count</span> * <span class="ruby-identifier">upvotes</span>
262 <span class="ruby-keyword">end</span>
263 <span class="ruby-keyword">end</span></pre>
270 <div class="title method-title" id="method-i-votes_count">
274 <a href="../classes/Votes.html#method-i-votes_count" name="method-i-votes_count" class="permalink">Link</a>
278 <div class="description">
279 <p>Return the total number of votes</p>
287 <div class="sourcecode">
289 <p class="source-link">
291 <a href="javascript:toggleSource('method-i-votes_count_source')" id="l_method-i-votes_count_source">show</a>
294 <div id="method-i-votes_count_source" class="dyn-source">
295 <pre><span class="ruby-comment"># File app/roles/votes.rb, line 29</span>
296 <span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">votes_count</span>
297 <span class="ruby-identifier">upvotes</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">downvotes</span>
298 <span class="ruby-keyword">end</span></pre>