Class: Quby::Compiler::Entities::QuestionOptgroup
- Inherits:
-
Object
- Object
- Quby::Compiler::Entities::QuestionOptgroup
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/quby/compiler/entities/question_optgroup.rb
Instance Attribute Summary collapse
-
#i18n_key ⇒ Object
readonly
Returns the value of attribute i18n_key.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(key, label:, i18n_key: nil) ⇒ QuestionOptgroup
constructor
A new instance of QuestionOptgroup.
- #key_in_use?(key) ⇒ Boolean
- #path_str ⇒ Object
-
#questions ⇒ Object
We don’t allow subquestions on select questions.
Constructor Details
#initialize(key, label:, i18n_key: nil) ⇒ QuestionOptgroup
Returns a new instance of QuestionOptgroup.
15 16 17 18 19 20 |
# File 'lib/quby/compiler/entities/question_optgroup.rb', line 15 def initialize(key, label:, i18n_key: nil) @key = key @label = label @i18n_key = i18n_key @options = [] end |
Instance Attribute Details
#i18n_key ⇒ Object (readonly)
Returns the value of attribute i18n_key.
11 12 13 |
# File 'lib/quby/compiler/entities/question_optgroup.rb', line 11 def i18n_key @i18n_key end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
10 11 12 |
# File 'lib/quby/compiler/entities/question_optgroup.rb', line 10 def key @key end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
12 13 14 |
# File 'lib/quby/compiler/entities/question_optgroup.rb', line 12 def label @label end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
13 14 15 |
# File 'lib/quby/compiler/entities/question_optgroup.rb', line 13 def @options end |
Instance Method Details
#key_in_use?(key) ⇒ Boolean
22 23 24 |
# File 'lib/quby/compiler/entities/question_optgroup.rb', line 22 def key_in_use?(key) @options.any? { _1.key_in_use?(key) } end |
#path_str ⇒ Object
31 32 33 |
# File 'lib/quby/compiler/entities/question_optgroup.rb', line 31 def path_str "#{question.path_str}:Optgroup:#{key}" end |
#questions ⇒ Object
We don’t allow subquestions on select questions
27 28 29 |
# File 'lib/quby/compiler/entities/question_optgroup.rb', line 27 def questions [] end |