Class: FallCli::Middleware::Browser

Inherits:
Base
  • Object
show all
Defined in:
lib/fallcli/middleware/browser.rb

Overview

Check if the client has set-up configuration yet.

Constant Summary collapse

SPLASH =
%{



             ';             .'
           ,':''           :',''
          '',,.:'         '',,,:',
        '',,,,..,'       '',,,,,.''
      .':,,,,,....'`    ';,,,,,,,..''
     '',,,,,,,.....',  ':,,,,,,,,...:'.
   ;',,,,,,,,,......''',,,,,,,,,,.....''
 `';,,,,,,,,,,.......',,,,,,,,,,,.......';
 ':,,,,,,,,,,,......```,,,,,,,,,,........'
  '',,,,,,,,,,.....`````,,,,,,,,,......,'`
   '',,,,,,,,,...`````````,,,,,,,.....:'
    :',,,,,,,,..```````````.,,,,,....''
     `',,,,,,,```````````````,,,,...';
       ':,,,.``````````````````,,..'.
        '',`````````````````````.,'`
        '::`````````````````````,.',
      `',,::,``````````````````:,..''
     :',,,::::```````````````:::,...''
    '',,,,::::,,```````````,::::,....:'
   ';,,,,,::::,,,.````````::::::,......'`
  ':,,,,,,::::,,,,,`` ``::::::::,.......':
 ':,,,,,,,::::,,,,,,. .;;:::::::,........'
  '',,,,,,::::,,,,,,.`;;::::::::,......;'`
   .';,,,,::::,,,,,,``,:::::::::,.....';
     '',,,::::,,,,,```,,::::::::,...''
      `';,:::,,,,,````,,,,::::::,.,':
        ;':::,,,..````,,,,,::::,,''
         '..:,,...````,,,,,,:::,.'
         '...,....````,,,,,,.:...'
         ;'.......````,,,,,,....''
           ''.....````,,,,,,..;'`
            :',...````,,,,,,,';
              ''`.````,,,,,''
               .':````,,,:',
                 ''```,,''
                  `';`;'.
                    :''

______ ___   _      _     _____  _     _____
|  ___/ _ \\ | |    | |   /  __ \\| |   |_   _|
| |_ / /_\\ \\| |    | |   | /  \\/| |     | |
|  _||  _  || |    | |   | |    | |     | |
| |  | | | || |____| |___| \\__/\\| |_____| |_
\\_|  \\_| |_/\\_____/\\_____/\\____/\\_____/\\___/
                                              V.#{FallCli::VERSION}
}

Constants inherited from Base

FallCli::Middleware::Base::CLEAR, FallCli::Middleware::Base::GREEN, FallCli::Middleware::Base::RED, FallCli::Middleware::Base::YELLOW

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from FallCli::Middleware::Base

Instance Method Details

#call(env) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/fallcli/middleware/browser.rb', line 64

def call(env)
  config = env["config"]

  say SPLASH

  sleep(2)

  songs = env['dropbox-client'].ls

  browser = FallCli::BrowserHelper.new(songs)

  Dispel::Screen.open do |screen|
    screen.draw show_ui(browser)

    Dispel::Keyboard.output do |key|
      case key
      when :up then browser.position_up
      when :down then browser.position_down
      when "q" then break
      end
      screen.draw show_ui(browser)
    end
  end

  @app.call(env)
end

#show_ui(filelist_obj) ⇒ Object



9
10
11
# File 'lib/fallcli/middleware/browser.rb', line 9

def show_ui filelist_obj
  ["\n", filelist_obj.show_files, "\nCurrent position: #{filelist_obj.position + 1} "].join("\n")
end