Class: Goodsheet::ValidationErrors

Inherits:
Array
  • Object
show all
Defined in:
lib/goodsheet/validation_errors.rb

Instance Method Summary collapse

Constructor Details

#initialize(limit = 0) ⇒ ValidationErrors

Returns a new instance of ValidationErrors.



5
6
7
# File 'lib/goodsheet/validation_errors.rb', line 5

def initialize(limit=0)
  @max_size = (limit==0 || limit.nil?) ? Float::INFINITY : limit
end

Instance Method Details

#add(line_number, row) ⇒ boolean

Add a potential error (will be added only if the row is not valid)

Parameters:

  • line_number (Fixnum)

    Line number (0-based).

Returns:

  • (boolean)

    Return false if the limit has been reached, true otherwise.



13
14
15
16
# File 'lib/goodsheet/validation_errors.rb', line 13

def add(line_number, row)
  self << ValidationError.new(line_number+1, row.errors) if row.invalid?
  self.size < @max_size
end

#valid?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/goodsheet/validation_errors.rb', line 18

def valid?
  empty?
end