Class: Runoff::Commands::Some

Inherits:
Command
  • Object
show all
Defined in:
lib/runoff/commands/some.rb

Class Method Summary collapse

Methods inherited from Command

get_file_writer_components

Class Method Details

.process(args, options = {}) ⇒ Object

Public: Exports a specified part of Skyoe chat history.

args - an array containing skype username options - a hash containing user provided options

Examples

Some.process ['username'], { from: '~/main.db' }


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/runoff/commands/some.rb', line 16

def self.process(args, options = {})
  file_writer, export_path = self.get_file_writer_components args, options
  format = Runoff::SkypeDataFormat.new

  file_writer.export_database_partially format, export_path, options.archive do |w, d|
    chatname_dataset = d.select(:chatname)
    chatnames = Set.new # Set is necessary to filter out duplicate chatnames.

    chatname_dataset.each { |row| chatnames.add format.normalize(row[:chatname]) }

    # In order to use indices we need an array.
    w.selected_entries = chatnames.to_a

    w.selected_entries.each_with_index { |e, i| puts "[#{i}] #{e}" }

    puts # Ensure a blank line.
    # Return the user response back to the FileWriter class.
    next ask("Specify which chats to export separating each number with a comma:")
  end
end