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
# File 'lib/gpuzzletime/app.rb', line 10

def initialize(args)
  @base_url = 'https://time.puzzle.ch'

  @command = (args[0] || :show).to_sym

  case @command
  when :show, :upload
    @date = named_dates(args[1] || 'last') || :all
  when :edit
    @file = args[1]
  else
    raise ArgumentError, "Unsupported Command #{@command}"
  end
end

Instance Method Details

#runObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/gpuzzletime/app.rb', line 25

def run
  case @command
  when :show
    fill_entries(@command)
    entries.each do |date, entries|
      puts date, '----------'
      entries.each do |entry|
        puts entry
      end
      puts nil
    end
  when :upload
    fill_entries(@command)
    entries.each do |date, entries|
      puts "Uploading #{date}"
      entries.each do |start, entry|
        open_browser(start, entry)
      end
    end
  when :edit
    launch_editor
  end
end