Method: Fech::Filing#rows_like

Defined in:
lib/fech/filing.rb

#rows_like(row_type, opts = {}) {|Hash| ... } ⇒ Array

Access all lines of the filing that match a given row type. Will return an Array of all available lines if called directly, or will yield the mapped rows one by one if a block is passed.

Parameters:

  • row_type (String, Regexp)

    a partial or complete name of the type of row desired

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :raw (Boolean)

    should the function return the data as an array that has not been mapped to column names

  • :include (Array)

    list of field names that should be included in the returned hash

Yields:

  • (Hash)

    each matched row’s data, as either a mapped hash or raw array

Returns:

  • (Array)

    the complete set of mapped hashes for matched lines



78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/fech/filing.rb', line 78

def rows_like(row_type, opts={}, &block)
  data = []
  each_row(:row_type => row_type) do |row|
    value = parse_row?(row, opts.merge(:parse_if => row_type))
    next if value == false
    if block_given?
      yield value
    else
      data << value if value
    end
  end
  block_given? ? nil : data
end