Class: Gotasku::RatingString
- Inherits:
-
String
- Object
- String
- Gotasku::RatingString
- Defined in:
- lib/gotasku/rating_string.rb
Instance Method Summary collapse
-
#convert ⇒ Object
convert string to number.
Instance Method Details
#convert ⇒ Object
convert string to number
4 5 6 7 8 9 10 |
# File 'lib/gotasku/rating_string.rb', line 4 def convert sum = self.slice(/sitesum:\d+/).slice(/\d+/).to_i num = self.slice(/sitenum:\d+/).slice(/\d+/).to_i # find the average or return the sum (if num is 0) num == 0 ? 0 : sum / num end |