Class: Quby::Compiler::DSL::TableBuilder
- Inherits:
-
Object
- Object
- Quby::Compiler::DSL::TableBuilder
- Includes:
- CallsCustomMethods, Helpers
- Defined in:
- lib/quby/compiler/dsl/table_builder.rb
Instance Attribute Summary
Attributes included from CallsCustomMethods
Instance Method Summary collapse
- #description(value) ⇒ Object
-
#initialize(panel, default_question_options: {}, **options) ⇒ TableBuilder
constructor
A new instance of TableBuilder.
- #question(key, **options, &block) ⇒ Object
- #text(value, **options) ⇒ Object
- #title(value) ⇒ Object
Methods included from Helpers
#check_question_keys_uniqueness, #image_alt, #image_tag, #video_tag
Methods included from CallsCustomMethods
#method_missing, #respond_to_missing?
Constructor Details
#initialize(panel, default_question_options: {}, **options) ⇒ TableBuilder
Returns a new instance of TableBuilder.
12 13 14 15 16 17 |
# File 'lib/quby/compiler/dsl/table_builder.rb', line 12 def initialize(panel, default_question_options: {}, **) @panel = panel @table = Entities::Table.new() @default_question_options = @panel.items << @table end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Quby::Compiler::DSL::CallsCustomMethods
Instance Method Details
#description(value) ⇒ Object
23 24 25 |
# File 'lib/quby/compiler/dsl/table_builder.rb', line 23 def description(value) @table.description = value end |
#question(key, **options, &block) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/quby/compiler/dsl/table_builder.rb', line 31 def question(key, **, &block) = @default_question_options.merge() .merge(table: @table, questionnaire: @panel.questionnaire) check_question_keys_uniqueness key, , @panel.questionnaire fail "You can't create a slider in a table at the moment" if [:as] == :slider question = QuestionBuilder.build(key, **, &block) @panel.questionnaire.register_question(question) @table.items << question @panel.items << question end |
#text(value, **options) ⇒ Object
27 28 29 |
# File 'lib/quby/compiler/dsl/table_builder.rb', line 27 def text(value, **) @table.items << Entities::Text.new(value.to_s, ) end |
#title(value) ⇒ Object
19 20 21 |
# File 'lib/quby/compiler/dsl/table_builder.rb', line 19 def title(value) @table.title = value end |