Class: Option

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/option.rb

Instance Method Summary collapse

Instance Method Details

#response_percentageObject

return the percentage of responses this option has



8
9
10
11
# File 'app/models/option.rb', line 8

def response_percentage
  return 0 unless self.poll.response_count >= 1
  sprintf("%0.1f", (self.response_count / self.poll.response_count.to_f) * 100.0)
end

#should_destroy?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'app/models/option.rb', line 13

def should_destroy?
  should_destroy.to_i == 1
end