class Quby::Questionnaires::Entities::Questions::CheckboxQuestion
Attributes
check_all_option[RW]
checkbox option that checks all other options on check
maximum_checked_allowed[RW]
checkbox option that allows to select a maximum amount of checkboxes
minimum_checked_required[RW]
checkbox option that forces to select a minimum amount of checkboxes
uncheck_all_option[RW]
checkbox option that unchecks all other options on check
Public Class Methods
new(key, options = {})
click to toggle source
Calls superclass method
Quby::Questionnaires::Entities::Question::new
# File lib/quby/questionnaires/entities/questions/checkbox_question.rb, line 20 def initialize(key, options = {}) super @check_all_option = options[:check_all_option] @uncheck_all_option = options[:uncheck_all_option] @maximum_checked_allowed = options[:maximum_checked_allowed] @minimum_checked_required = options[:minimum_checked_required] end
Public Instance Methods
answer_keys()
click to toggle source
# File lib/quby/questionnaires/entities/questions/checkbox_question.rb, line 40 def answer_keys # Some options don't have a key (inner_title), they are stripped. options.map { |opt| opt.input_key }.compact end
as_json(options = {})
click to toggle source
Calls superclass method
Quby::Questionnaires::Entities::Question#as_json
# File lib/quby/questionnaires/entities/questions/checkbox_question.rb, line 45 def as_json(options = {}) super.merge(options: @options.as_json) end
claimed_keys()
click to toggle source
# File lib/quby/questionnaires/entities/questions/checkbox_question.rb, line 36 def claimed_keys [key] end
to_codebook(questionnaire, opts = {})
click to toggle source
# File lib/quby/questionnaires/entities/questions/checkbox_question.rb, line 49 def to_codebook(questionnaire, opts = {}) options.map do |option| option.to_codebook(questionnaire, opts) end.compact.join("\n\n") end
variable_descriptions()
click to toggle source
# File lib/quby/questionnaires/entities/questions/checkbox_question.rb, line 29 def variable_descriptions options.each_with_object(key => context_free_title) do |option, hash| next if option.input_key.blank? hash[option.input_key] = "#{context_free_title} - #{option.description}" end.with_indifferent_access end