Class: Gpuzzletime::App
- Inherits:
-
Object
- Object
- Gpuzzletime::App
- Defined in:
- lib/gpuzzletime/app.rb
Overview
Wrapper for everything
Constant Summary collapse
- CONFIGURATION_DEFAULTS =
{ base_url: 'https://time.puzzle.ch', rounding: 15, dir: Pathname.new('~/.config/gpuzzletime')., }.freeze
Instance Method Summary collapse
-
#initialize(args) ⇒ App
constructor
A new instance of App.
- #run ⇒ Object
Constructor Details
#initialize(args) ⇒ App
Returns a new instance of App.
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/gpuzzletime/app.rb', line 16 def initialize(args) @config = load_config(CONFIGURATION_DEFAULTS[:dir].join('config')) @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
#run ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/gpuzzletime/app.rb', line 30 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 |