Class: CaTissue::ExtractCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/catissue/extract/command.rb

Overview

ExtractCommand extracts target CaTissue domain class objects whose modification date is within a time interval to a CSV file based on a CSV mapping file.

Instance Method Summary collapse

Constructor Details

#initializeExtractCommand

Creates a new ExtractCommand. The delta range is given by the required :since option and optional :before option. The default before value is the current DateTime. These are used to build a Delta which is passed to CaRuby::Command#initialize as the :ids option. The :log option specifies a log file. Other supported options are described in CaTissue::Extractor#initialize.

Raises:

  • (ArgumentError)


15
16
17
18
19
20
21
22
23
24
# File 'lib/catissue/extract/command.rb', line 15

def initialize
  # prep the options
  since = opts.delete(:since)
  raise ArgumentError.new("Missing required beginning of date selection range option") unless since
  before = opts.delete(:before) || DateTime.now
   # the data acquirer
  opts[:ids] = Delta.new(@target, since, before)
  # make the command
  super(opts)
end

Instance Method Details

#runObject

Starts an Extractor with the command-line options.



27
28
29
# File 'lib/catissue/extract/command.rb', line 27

def run
  super { |opts| Extractor.new(opts) }
end