Class: Quby::Compiler::Entities::QuestionOption
- Inherits:
-
Object
- Object
- Quby::Compiler::Entities::QuestionOption
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/quby/compiler/entities/question_option.rb
Constant Summary collapse
- MARKDOWN_ATTRIBUTES =
%w(description).freeze
Instance Attribute Summary collapse
-
#context_free_description ⇒ Object
readonly
Returns the value of attribute context_free_description.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#hidden ⇒ Object
readonly
Returns the value of attribute hidden.
-
#hides_questions ⇒ Object
readonly
Returns the value of attribute hides_questions.
-
#i18n_key ⇒ Object
readonly
Returns the value of attribute i18n_key.
-
#inner_title ⇒ Object
readonly
for scale/radio/checbox questions, piece of of html that is rendered between the options.
-
#input_key ⇒ Object
readonly
Returns the value of attribute input_key.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#placeholder ⇒ Object
readonly
for select questions, option with no value and key is removed from answers if this one is selected.
-
#question ⇒ Object
readonly
Returns the value of attribute question.
-
#questions ⇒ Object
readonly
Returns the value of attribute questions.
-
#shows_questions ⇒ Object
readonly
Returns the value of attribute shows_questions.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
-
#view_id ⇒ Object
readonly
Returns the value of attribute view_id.
Instance Method Summary collapse
-
#initialize(key, question, options = {}) ⇒ QuestionOption
constructor
A new instance of QuestionOption.
- #inner_title? ⇒ Boolean
- #key_in_use?(k) ⇒ Boolean
- #path_str ⇒ Object
Constructor Details
#initialize(key, question, options = {}) ⇒ QuestionOption
Returns a new instance of QuestionOption.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/quby/compiler/entities/question_option.rb', line 35 def initialize(key, question, = {}) @key = key @question = question @value = [:value] @label = [:label] @description = [:description] @context_free_description = [:context_free_description] @questions = [] @inner_title = [:inner_title] @hides_questions = [:hides_questions] || [] @shows_questions = [:shows_questions] || [] @hidden = [:hidden] || false @placeholder = [:placeholder] || false question.extra_data[:placeholder] = key if @placeholder @input_key = (question.type == :check_box ? @key : "#{question.key}_#{key}".to_sym) @view_id = "answer_#{input_key}" @i18n_key = [:i18n_key] end |
Instance Attribute Details
#context_free_description ⇒ Object (readonly)
Returns the value of attribute context_free_description.
16 17 18 |
# File 'lib/quby/compiler/entities/question_option.rb', line 16 def context_free_description @context_free_description end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
16 17 18 |
# File 'lib/quby/compiler/entities/question_option.rb', line 16 def description @description end |
#hidden ⇒ Object (readonly)
Returns the value of attribute hidden.
25 26 27 |
# File 'lib/quby/compiler/entities/question_option.rb', line 25 def hidden @hidden end |
#hides_questions ⇒ Object (readonly)
Returns the value of attribute hides_questions.
23 24 25 |
# File 'lib/quby/compiler/entities/question_option.rb', line 23 def hides_questions @hides_questions end |
#i18n_key ⇒ Object (readonly)
Returns the value of attribute i18n_key.
33 34 35 |
# File 'lib/quby/compiler/entities/question_option.rb', line 33 def i18n_key @i18n_key end |
#inner_title ⇒ Object (readonly)
for scale/radio/checbox questions, piece of of html that is rendered between the options
21 22 23 |
# File 'lib/quby/compiler/entities/question_option.rb', line 21 def inner_title @inner_title end |
#input_key ⇒ Object (readonly)
Returns the value of attribute input_key.
32 33 34 |
# File 'lib/quby/compiler/entities/question_option.rb', line 32 def input_key @input_key end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
12 13 14 |
# File 'lib/quby/compiler/entities/question_option.rb', line 12 def key @key end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
15 16 17 |
# File 'lib/quby/compiler/entities/question_option.rb', line 15 def label @label end |
#placeholder ⇒ Object (readonly)
for select questions, option with no value and key is removed from answers if this one is selected.
28 29 30 |
# File 'lib/quby/compiler/entities/question_option.rb', line 28 def placeholder @placeholder end |
#question ⇒ Object (readonly)
Returns the value of attribute question.
30 31 32 |
# File 'lib/quby/compiler/entities/question_option.rb', line 30 def question @question end |
#questions ⇒ Object (readonly)
Returns the value of attribute questions.
19 20 21 |
# File 'lib/quby/compiler/entities/question_option.rb', line 19 def questions @questions end |
#shows_questions ⇒ Object (readonly)
Returns the value of attribute shows_questions.
24 25 26 |
# File 'lib/quby/compiler/entities/question_option.rb', line 24 def shows_questions @shows_questions end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
13 14 15 |
# File 'lib/quby/compiler/entities/question_option.rb', line 13 def value @value end |
#view_id ⇒ Object (readonly)
Returns the value of attribute view_id.
31 32 33 |
# File 'lib/quby/compiler/entities/question_option.rb', line 31 def view_id @view_id end |
Instance Method Details
#inner_title? ⇒ Boolean
55 56 57 |
# File 'lib/quby/compiler/entities/question_option.rb', line 55 def inner_title? inner_title.present? end |
#key_in_use?(k) ⇒ Boolean
59 60 61 62 63 |
# File 'lib/quby/compiler/entities/question_option.rb', line 59 def key_in_use?(k) return true if k == input_key @questions.each { |q| return true if q.key_in_use?(k) } false end |
#path_str ⇒ Object
65 66 67 |
# File 'lib/quby/compiler/entities/question_option.rb', line 65 def path_str "#{question.path_str}:Option:#{key}" end |