Class: Linkage::ResultSets::CSV

Inherits:
Linkage::ResultSet show all
Defined in:
lib/linkage/result_sets/csv.rb

Overview

ResultSets::CSV is a subclass of ResultSet that makes it convenient to set up a ScoreSets::CSV and MatchSets::CSV at the same time. For example:

result_set = Linkage::ResultSets::CSV.new('/some/path')

Or by using ResultSet.[]:

result_set = Linkage::ResultSet['csv'].new('/some/path')

ResultSets::CSV.new takes either a directory name as its argument or a Hash of options. Passing in a directory name is equivalent to passing in a Hash with the :dir key. For example:

result_set = Linkage::ResultSet['csv'].new('/some/path')

is the same as:

result_set = Linkage::ResultSet['csv'].new({:dir => '/some/path'})

The :dir option lets you specify the parent directory for the score set and result set files (which are scores.csv and results.csv by default).

The only other relevant option is :overwrite, which controls whether or not overwriting existing files is permitted.

Instance Method Summary collapse

Methods inherited from Linkage::ResultSet

klass_for, register

Constructor Details

#initialize(dir) ⇒ CSV #initialize(options) ⇒ CSV

Returns a new instance of CSV.

Overloads:

  • #initialize(dir) ⇒ CSV

    Parameters:

    • dir (String)

      parent directory of CSV files

  • #initialize(options) ⇒ CSV

    Parameters:

    • options (Hash)

    Options Hash (options):

    • :dir (String)

      parent directory of CSV files

    • :overwrite (Boolean) — default: false

      whether or not to allow overwriting existing files



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/linkage/result_sets/csv.rb', line 47

def initialize(dir_or_options = nil)
  @options =
    case dir_or_options
    when nil
      {}
    when String
      {:dir => dir_or_options}
    when Hash
      dir_or_options
    else
      raise ArgumentError, "expected nil, a String, or a Hash, got #{dir_or_options.class}"
    end
end

Instance Method Details

#match_setObject



65
66
67
# File 'lib/linkage/result_sets/csv.rb', line 65

def match_set
  @match_set ||= MatchSet['csv'].new(@options)
end

#score_setObject



61
62
63
# File 'lib/linkage/result_sets/csv.rb', line 61

def score_set
  @score_set ||= ScoreSet['csv'].new(@options)
end