Class: Coltrane::UI::Views::View
- Inherits:
-
Object
- Object
- Coltrane::UI::Views::View
show all
- Defined in:
- lib/coltrane/ui/views/view.rb
Direct Known Subclasses
Chords, CustomProgression, FindChordByNotes, FindCommonChordsInScales, FindProgressionsFromChords, FindScale, FindScaleByChords, FindScaleByNotes, Index, Notes, Progressions, Scales, ShowChord, ShowProgression, ShowScale
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(**params) ⇒ View
Returns a new instance of View.
30
31
32
|
# File 'lib/coltrane/ui/views/view.rb', line 30
def initialize(**params)
@params = params
end
|
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
5
6
7
|
# File 'lib/coltrane/ui/views/view.rb', line 5
def params
@params
end
|
#path ⇒ Object
Returns the value of attribute path.
5
6
7
|
# File 'lib/coltrane/ui/views/view.rb', line 5
def path
@path
end
|
Class Method Details
.inherited(subclass) ⇒ Object
8
9
10
11
|
# File 'lib/coltrane/ui/views/view.rb', line 8
def inherited(subclass)
@questions ||= {}
subclass.instance_variable_set(:@questions, @questions.deep_dup)
end
|
.questions(question_data) ⇒ Object
13
14
15
16
|
# File 'lib/coltrane/ui/views/view.rb', line 13
def questions(question_data)
@questions.merge!(question_data)
@questions.compact!
end
|
.render(**params) ⇒ Object
22
23
24
25
26
27
|
# File 'lib/coltrane/ui/views/view.rb', line 22
def render(**params)
remaining_questions = @questions.slice(*(@questions.keys - params.keys))
return { questions: remaining_questions, **params } if remaining_questions.any?
view = new(**params)
{ content: Commands::Render.run(view.render), **params }
end
|
.set_path(value) ⇒ Object
18
19
20
|
# File 'lib/coltrane/ui/views/view.rb', line 18
def set_path(value)
@params[:path] = value
end
|
Instance Method Details
#ensure_param(param_name, &block) ⇒ Object
42
43
44
|
# File 'lib/coltrane/ui/views/view.rb', line 42
def ensure_param(param_name, &block)
@params[param_name] = block.call if @params[param_name].nil?
end
|
#go_to(path, **params) ⇒ Object
38
39
40
|
# File 'lib/coltrane/ui/views/view.rb', line 38
def go_to(path, **params)
end
|
#output(object) ⇒ Object
34
35
36
|
# File 'lib/coltrane/ui/views/view.rb', line 34
def output(object)
self.class.output(object)
end
|