Class: Gambiarra::UI::CreateView

Inherits:
BaseView show all
Defined in:
lib/gambiarra/ui/views/create_view.rb

Instance Attribute Summary

Attributes inherited from View

#params, #path

Instance Method Summary collapse

Methods inherited from BaseView

#project_constant, #project_name, #thor

Methods inherited from View

#ensure_param, #go_to, inherited, #initialize, #output, questions, render, respond, set_path

Constructor Details

This class inherits a constructor from Gambiarra::View

Instance Method Details

#renderObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/gambiarra/ui/views/create_view.rb', line 8

def render
  view = params[:view_name].gsub(/ |_|-/, '_').downcase
  thor.create_file("lib/#{project_name}/ui/views/#{view}.rb", <<~RUBY)
    module #{project_constant}
      module UI
        # you can also inherit from your other views, questions will be merged
        # assign them to nil to erase them
        class #{view.camelize} < BaseView
          questions({
            question_name: {
              statement: 'Welcome to #{project_name.titleize}',
              options: ['exit'] # delete options to make this free form
            }
          })
        end

        def render
          # might want render something here after questions are answered
        end
      end
    end

  RUBY
end