Class: BioDSL::Dump

Inherits:
Object
  • Object
show all
Defined in:
lib/BioDSL/commands/dump.rb

Overview

Dump records in stream to STDOUT.

dump outputs records from the stream to STDOUT.

Usage

dump([first: <uint> |last: <uint>])

Options

  • first <uint> - Only dump the first number of records.

  • last <uint> - Only dump the last number of records.

Examples

To dump all records in the stream:

dump

To dump only the first 10 records:

dump(first: 10)

To dump only the last 10 records:

dump(last: 10)

Constant Summary

STATS =
%i(records_in records_out)

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Dump

Constructor for the Dump class.

Parameters:

  • options (Hash)

    Options hash.

Options Hash (options):

  • :first (Integer)

    Dump first number of records.

  • :last (Integer)

    Dump last number of records.



65
66
67
68
69
# File 'lib/BioDSL/commands/dump.rb', line 65

def initialize(options)
  @options = options

  check_options
end

Instance Method Details

#lmbProc

Return a lambda for the dump command.

Returns:

  • (Proc)

    Returns the dump command lambda.



74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/BioDSL/commands/dump.rb', line 74

def lmb
  lambda do |input, output, status|
    status_init(status, STATS)

    if @options[:first]
      dump_first(input, output)
    elsif @options[:last]
      dump_last(input, output)
    else
      dump_all(input, output)
    end
  end
end