Class: Quby::Compiler::Entities::Panel
- Defined in:
- lib/quby/compiler/entities/panel.rb
Instance Attribute Summary collapse
-
#items ⇒ Object
Returns the value of attribute items.
-
#key ⇒ Object
Returns the value of attribute key.
-
#questionnaire ⇒ Object
readonly
Returns the value of attribute questionnaire.
-
#title ⇒ Object
Returns the value of attribute title.
Attributes inherited from Item
#presentation, #raw_content, #switch_cycle
Instance Method Summary collapse
- #index ⇒ Object
-
#initialize(options = {}) ⇒ Panel
constructor
A new instance of Panel.
- #next ⇒ Object
- #prev ⇒ Object
- #validations ⇒ Object
Methods inherited from Item
Constructor Details
#initialize(options = {}) ⇒ Panel
Returns a new instance of Panel.
12 13 14 15 16 17 |
# File 'lib/quby/compiler/entities/panel.rb', line 12 def initialize( = {}) @questionnaire = [:questionnaire] @title = [:title] @key = [:key] @items = [:items] || [] end |
Instance Attribute Details
#items ⇒ Object
Returns the value of attribute items.
8 9 10 |
# File 'lib/quby/compiler/entities/panel.rb', line 8 def items @items end |
#key ⇒ Object
Returns the value of attribute key.
9 10 11 |
# File 'lib/quby/compiler/entities/panel.rb', line 9 def key @key end |
#questionnaire ⇒ Object (readonly)
Returns the value of attribute questionnaire.
10 11 12 |
# File 'lib/quby/compiler/entities/panel.rb', line 10 def questionnaire @questionnaire end |
#title ⇒ Object
Returns the value of attribute title.
7 8 9 |
# File 'lib/quby/compiler/entities/panel.rb', line 7 def title @title end |
Instance Method Details
#index ⇒ Object
19 20 21 |
# File 'lib/quby/compiler/entities/panel.rb', line 19 def index @questionnaire.panels.index(self) end |
#next ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/quby/compiler/entities/panel.rb', line 23 def next this_panel_index = index if this_panel_index < @questionnaire.panels.size return @questionnaire.panels[this_panel_index + 1] else nil end end |
#prev ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/quby/compiler/entities/panel.rb', line 33 def prev this_panel_index = index if this_panel_index > 0 return @questionnaire.panels[this_panel_index - 1] else nil end end |
#validations ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/quby/compiler/entities/panel.rb', line 43 def validations vals = {} items.each do |item| if item.is_a? Question item..each do |opt| if opt.questions opt.questions.each do |q| vals[q.key] = q.validations end end end vals[item.key] = item.validations end end vals end |