Class: Saikuro::BaseFormater

Inherits:
Object
  • Object
show all
Defined in:
lib/saikuro/base_formater.rb

Direct Known Subclasses

ParseStateFormater, TokenCounterFormater

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(out, filter = nil) ⇒ BaseFormater

Returns a new instance of BaseFormater.



5
6
7
8
9
# File 'lib/saikuro/base_formater.rb', line 5

def initialize(out, filter = nil)
  @out = out
  @filter = filter
  reset_data
end

Instance Attribute Details

#currentObject

Returns the value of attribute current.



3
4
5
# File 'lib/saikuro/base_formater.rb', line 3

def current
  @current
end

#errorsObject

Returns the value of attribute errors.



3
4
5
# File 'lib/saikuro/base_formater.rb', line 3

def errors
  @errors
end

#warningsObject

Returns the value of attribute warnings.



3
4
5
# File 'lib/saikuro/base_formater.rb', line 3

def warnings
  @warnings
end

Instance Method Details

#reset_dataObject



25
26
27
28
29
# File 'lib/saikuro/base_formater.rb', line 25

def reset_data
  @warnings = Array.new
  @errors = Array.new
  @current = ""
end

#warn_error?(num, marker) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/saikuro/base_formater.rb', line 11

def warn_error?(num, marker)
  klass = ""

  if @filter.error?(num)
    klass = ' class="error"'
    @errors<< [@current, marker, num]
  elsif @filter.warn?(num)
    klass = ' class="warning"'
    @warnings<< [@current, marker, num]
  end

  klass
end