Class: Gpuzzletime::App

Inherits:
Object
  • Object
show all
Defined in:
lib/gpuzzletime/app.rb

Overview

Wrapper for everything

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ App

Returns a new instance of App.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/gpuzzletime/app.rb', line 10

def initialize(args)
  @config = Configuration.instance
  command = (args[0] || :show).to_sym

  @command = case command
             when :show
               @date = NamedDate.new.date(args[1])
               Gpuzzletime::Command::Show.new(@config)
             when :upload
               @date = NamedDate.new.date(args[1])
               Gpuzzletime::Command::Upload.new(@config)
             when :edit
               Gpuzzletime::Command::Edit.new(@config, args[1])
             else
               raise ArgumentError, "Unsupported Command #{@command}"
             end
end

Instance Method Details

#runObject



28
29
30
31
32
33
34
35
# File 'lib/gpuzzletime/app.rb', line 28

def run
  if @command.needs_entries?
    fill_entries
    @command.entries = entries
  end

  @command.run
end