module NoSE::Backend::FileBackend::RowMatcher

Provide some helper functions which allow the matching of rows based on a set of list of conditions

Public Instance Methods

row_matches?(row, conditions) click to toggle source

Check if a row matches the given condition @return [Boolean]

# File lib/nose/backend/file.rb, line 85
def row_matches?(row, conditions)
  row_matches_eq?(row, conditions) &&
    row_matches_range?(row, conditions)
end
row_matches_eq?(row, conditions) click to toggle source

Check if a row matches the given condition on equality predicates @return [Boolean]

# File lib/nose/backend/file.rb, line 92
def row_matches_eq?(row, conditions)
  @eq_fields.all? do |field|
    row[field.id] == conditions.find { |c| c.field == field }.value
  end
end
row_matches_range?(row, conditions) click to toggle source

Check if a row matches the given condition on the range predicate @return [Boolean]

# File lib/nose/backend/file.rb, line 100
def row_matches_range?(row, conditions)
  return true if @range_field.nil?

  range_cond = conditions.find { |c| c.field == @range_field }
  row[@range_field.id].send range_cond.operator, range_cond.value
end