Class: FactoryForm::Rating

Inherits:
Field
  • Object
show all
Defined in:
lib/factoryform/rating.rb

Overview

Rating has different scales

Instance Attribute Summary collapse

Attributes inherited from Field

#field_type, #hint, #id, #label, #required, #unique, #validation_format

Instance Method Summary collapse

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(options={})
  options[:field_type] = "rating"
  super(options)
  
  # Default is 2 for number of scales
  if options[:scale] && options[:scale].to_i > 1
    self.scale = options[:scale].to_i
  else
    raise(ParameterExpectedException, "Missing rating scale (should be greater than or equal to 2)")
  end

  self.from_label = options[:from_label] || ""
  self.to_label = options[:to_label] || ""
      
end

Instance Attribute Details

#from_labelObject

Returns the value of attribute from_label.



4
5
6
# File 'lib/factoryform/rating.rb', line 4

def from_label
  @from_label
end

#scaleObject

Returns the value of attribute scale.



4
5
6
# File 'lib/factoryform/rating.rb', line 4

def scale
  @scale
end

#to_labelObject

Returns the value of attribute to_label.



4
5
6
# File 'lib/factoryform/rating.rb', line 4

def to_label
  @to_label
end