Class: FactoryForm::Rating
Overview
Rating has different scales
Instance Attribute Summary collapse
-
#from_label ⇒ Object
Returns the value of attribute from_label.
-
#scale ⇒ Object
Returns the value of attribute scale.
-
#to_label ⇒ Object
Returns the value of attribute to_label.
Attributes inherited from Field
#field_type, #hint, #id, #label, #required, #unique, #validation_format
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Rating
constructor
A new instance of Rating.
Constructor Details
#initialize(options = {}) ⇒ Rating
Returns a new instance of Rating.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/factoryform/rating.rb', line 6 def initialize(={}) [:field_type] = "rating" super() # Default is 2 for number of scales if [:scale] && [:scale].to_i > 1 self.scale = [:scale].to_i else raise(ParameterExpectedException, "Missing rating scale (should be greater than or equal to 2)") end self.from_label = [:from_label] || "" self.to_label = [:to_label] || "" end |
Instance Attribute Details
#from_label ⇒ Object
Returns the value of attribute from_label.
4 5 6 |
# File 'lib/factoryform/rating.rb', line 4 def from_label @from_label end |
#scale ⇒ Object
Returns the value of attribute scale.
4 5 6 |
# File 'lib/factoryform/rating.rb', line 4 def scale @scale end |
#to_label ⇒ Object
Returns the value of attribute to_label.
4 5 6 |
# File 'lib/factoryform/rating.rb', line 4 def to_label @to_label end |