Class: AskAwesomely::Field::Rating
- Defined in:
- lib/ask_awesomely/field/rating.rb
Constant Summary collapse
- POSSIBLE_STEPS =
3..10
- SHAPES =
%i( stars thumbs_up )
Constants inherited from Field
Instance Attribute Summary
Attributes inherited from Field
Instance Method Summary collapse
-
#initialize ⇒ Rating
constructor
A new instance of Rating.
- #shape(shape) ⇒ Object
- #steps(steps) ⇒ Object
Methods inherited from Field
#ask, #description, of_type, #ref, #required, #skip, #tags
Methods included from JsonBuilder
Constructor Details
#initialize ⇒ Rating
Returns a new instance of Rating.
10 11 12 |
# File 'lib/ask_awesomely/field/rating.rb', line 10 def initialize(*) super end |
Instance Method Details
#shape(shape) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/ask_awesomely/field/rating.rb', line 22 def shape(shape) unless SHAPES.include?(shape) raise ArgumentError, "shape must be one of: #{SHAPES.join(", ")}" end @state.shape = shape end |
#steps(steps) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/ask_awesomely/field/rating.rb', line 14 def steps(steps) unless POSSIBLE_STEPS.cover?(steps) raise ArgumentError, "number of steps must be between #{POSSIBLE_STEPS.begin} and #{POSSIBLE_STEPS.end}" end @state.steps = steps end |