Class: Hank::FileSelector

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/hank/file_selector.rb

Overview

Interactive curses-based file selection interface

Instance Method Summary collapse

Constructor Details

#initialize(initial_files = nil) ⇒ FileSelector

Returns a new instance of FileSelector.



12
13
14
15
16
17
18
19
# File 'lib/hank/file_selector.rb', line 12

def initialize(initial_files = nil)
  @initial_files = T.let(initial_files || [], T::Array[String])
  @selected_files = T.let(@initial_files.dup, T::Array[String])
  @current_path = T.let(Pathname.new('/'), Pathname)
  @file_list = T.let([], T::Array[String])
  @current_index = T.let(0, Integer)
  @offset = T.let(0, Integer)
end

Instance Method Details

#runObject



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/hank/file_selector.rb', line 22

def run
  init_curses
  begin
    load_files
    draw_screen
    handle_input
  ensure
    close_curses
  end

  @selected_files.empty? ? nil : @selected_files
end