Class: Merrol::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/merrol/lib/application.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(working_dir, paths) ⇒ Application

Returns a new instance of Application.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/merrol/lib/application.rb', line 5

def initialize working_dir, paths
  @views = WidgetBuilder.build :main, :status_bar, :hbox, :file_list, :scroll_bars, :edit, :file_status, :file_path
  main_view = @views[:main]
  commands = Commands.new main_view

  @controllers = {}
  controller_paths = Dir[File.app_relative('lib/merrol/controllers') + '/*_controller.rb']
  controller_paths.each do |controller|
    controller = File.basename(controller, '.rb')
    name = controller.gsub(/_controller/, '')
    @controllers[name] = eval(controller.classify).new commands, @views
  end

  @controllers['main'].working_dir = working_dir
  @controllers['file'].load_all paths

  # TODO: move both to a controller
  @views[:file_path].text = paths.last if paths.last
  @views[:edit].grab_focus

  main_view.show_all
end

Instance Attribute Details

#controllersObject (readonly)

Returns the value of attribute controllers.



3
4
5
# File 'lib/merrol/lib/application.rb', line 3

def controllers
  @controllers
end

#viewsObject (readonly)

Returns the value of attribute views.



3
4
5
# File 'lib/merrol/lib/application.rb', line 3

def views
  @views
end