Class: Runoff::Commandline::All
- Defined in:
- lib/runoff/commandline/all.rb
Overview
Public: A command class that is used to export all chat history.
Examples
command = All.new { archive: true }
command.execute [ 'skype_username' ]
Instance Attribute Summary
Attributes inherited from Command
Instance Method Summary collapse
-
#execute(args) ⇒ Object
Public: executes the command.
-
#initialize(options = {}) ⇒ All
constructor
Public: initialize a new All command object.
Constructor Details
#initialize(options = {}) ⇒ All
Public: initialize a new All command object.
options - A Hash of commandline options (default { archive: true, adapter: ‘TxtAdapter’ }).
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/runoff/commandline/all.rb', line 16 def initialize( = {}) @options = @parser = OptionParser.new do |opts| opts. = 'Exports all chats: runoff all [SKYPE_USERNAME] [OPTIONS]' opts.on '-h', '--help', 'Displays help' do puts opts exit end opts.on '-f', '--from PATH', 'Specifies the location of the database file (main.db)' do |path| @options[:from] = path end opts.on '-d', '--destination PATH', 'Changes the default path for the exported files' do |path| @options[:destination] = path end opts.on '-a', '--[no-]archive', 'Toggles archiving feature' do |enable| @options[:archive] = enable end opts.on '-A', '--adapter [NAME]', 'Uses a specific file type adapter' do |adapter| @options[:adapter] = adapter.capitalize + 'Adapter' end end end |
Instance Method Details
#execute(args) ⇒ Object
Public: executes the command.
args - An Array of commandline arguments.
46 47 48 49 50 |
# File 'lib/runoff/commandline/all.rb', line 46 def execute(args) super args do |chat, file_writer| file_writer.write chat. end end |