Top Level Namespace
Defined Under Namespace
Modules: Exfuz
Instance Method Summary collapse
- #candidate_by(candidates, line, sep: ':') ⇒ Object
- #main ⇒ Object
- #read_data(xlsxs, candidates = [], status) ⇒ Object
Instance Method Details
#candidate_by(candidates, line, sep: ':') ⇒ Object
20 21 22 23 |
# File 'lib/exfuz/main.rb', line 20 def candidate_by(candidates, line, sep: ':') lnum = line.split(sep)[0] candidates[lnum.to_i - 1] end |
#main ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/exfuz/main.rb', line 25 def main xlsxs = Dir.glob('**/[^~$]*.xlsx') status = Exfuz::Status.new(xlsxs.size) candidates = Exfuz::Candidates.new key_map = Exfuz::KeyMap.new screen = Exfuz::Screen.new(status, key_map, candidates) screen.init Curses.close_screen screen.init Thread.new do sleep 0.01 read_data(xlsxs, candidates, status) end loop do unless Thread.list.find { |t| t.name == 'wating_for_input' } in_t = Thread.new do screen.rerender if screen.changed_state? end in_t.name = 'wating_for_input' end screen.wait_input break if screen.closed? end end |
#read_data(xlsxs, candidates = [], status) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/exfuz/main.rb', line 3 def read_data(xlsxs, candidates = [], status) xlsxs.each_with_index do |xlsx, _idx| p = Exfuz::Parser.new(xlsx) p.parse p.each_cell_with_all do |cell| b = Exfuz::BookName.new(cell[:book_name]) s = Exfuz::SheetName.new(cell[:sheet_name]) c = Exfuz::Cell.new(address: cell[:cell], value: cell[:value]) candidates.push(Exfuz::Position.new([{ book_name: b }, { sheet_name: s }, { textable: c }])) end status.update(1) sleep 1 end candidates.close_push end |