Class: RBS::CLI::Validate::Errors

Inherits:
Object
  • Object
show all
Defined in:
lib/rbs/cli/validate.rb

Instance Method Summary collapse

Constructor Details

#initialize(limit:) ⇒ Errors

Returns a new instance of Errors.



7
8
9
10
# File 'lib/rbs/cli/validate.rb', line 7

def initialize(limit:)
  @limit = limit
  @errors = []
end

Instance Method Details

#add(error) ⇒ Object



12
13
14
15
# File 'lib/rbs/cli/validate.rb', line 12

def add(error)
  @errors << error
  finish if @limit == 1
end

#finishObject



25
26
27
28
29
30
31
32
33
34
# File 'lib/rbs/cli/validate.rb', line 25

def finish
  unless @errors.empty?
    @errors.each do |error|
      RBS.logger.error(build_message(error))
    end
    throw @tag, 1
  end

  0
end

#try(&block) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/rbs/cli/validate.rb', line 17

def try(&block)
  catch(:finish) do |tag|
    @tag = tag
    yield
    finish()
  end
end