Class: Fdbq::Question
- Inherits:
-
Object
- Object
- Fdbq::Question
- Defined in:
- lib/fdbq/question.rb
Instance Attribute Summary collapse
-
#hint ⇒ Object
Returns the value of attribute hint.
-
#label ⇒ Object
Returns the value of attribute label.
-
#name ⇒ Object
Returns the value of attribute name.
-
#placeholder ⇒ Object
Returns the value of attribute placeholder.
-
#required ⇒ Object
Returns the value of attribute required.
-
#type ⇒ Object
Returns the value of attribute type.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #answered?(answers) ⇒ Boolean
-
#initialize(attrs = {}) ⇒ Question
constructor
A new instance of Question.
- #param_key ⇒ Object
- #required? ⇒ Boolean
Constructor Details
#initialize(attrs = {}) ⇒ Question
Returns a new instance of Question.
5 6 7 8 9 |
# File 'lib/fdbq/question.rb', line 5 def initialize(attrs = {}) attrs.to_h.each_pair do |k, v| self.send("#{k}=", v) end end |
Instance Attribute Details
#hint ⇒ Object
Returns the value of attribute hint.
3 4 5 |
# File 'lib/fdbq/question.rb', line 3 def hint @hint end |
#label ⇒ Object
Returns the value of attribute label.
3 4 5 |
# File 'lib/fdbq/question.rb', line 3 def label @label end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/fdbq/question.rb', line 3 def name @name end |
#placeholder ⇒ Object
Returns the value of attribute placeholder.
3 4 5 |
# File 'lib/fdbq/question.rb', line 3 def placeholder @placeholder end |
#required ⇒ Object
Returns the value of attribute required.
3 4 5 |
# File 'lib/fdbq/question.rb', line 3 def required @required end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'lib/fdbq/question.rb', line 3 def type @type end |
#value ⇒ Object
Returns the value of attribute value.
3 4 5 |
# File 'lib/fdbq/question.rb', line 3 def value @value end |
Instance Method Details
#answered?(answers) ⇒ Boolean
15 16 17 |
# File 'lib/fdbq/question.rb', line 15 def answered?(answers) answers.to_h.stringify_keys[param_key].present? end |
#param_key ⇒ Object
11 12 13 |
# File 'lib/fdbq/question.rb', line 11 def param_key name.to_s end |
#required? ⇒ Boolean
19 20 21 |
# File 'lib/fdbq/question.rb', line 19 def required? !!required end |