Class: JSLint::Result

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

Instance Method Summary collapse

Constructor Details

#initialize(valid, errors) ⇒ Result

Returns a new instance of Result.



27
28
29
30
# File 'lib/jslint.rb', line 27

def initialize(valid, errors)
  @valid = valid
  @errors = errors
end

Instance Method Details

#error_messagesObject

Public: A nicely formatted list of errors with their line number.

Returns an Array of Strings.



44
45
46
47
48
49
50
# File 'lib/jslint.rb', line 44

def error_messages
  # @errors will have a 'nil' last element if JSLINT it hit a catastrophic
  # error before it finished looking at the whole file, so we 'compact'.
  @errors.compact.map {|e|
    "#{e['line']}:#{e['character']}: #{e['reason']}"
  }
end

#valid?Boolean

Public: Did the JavaScript source pass JSLint without errors?

This is the return value of the JSLINT() function.

Returns true iff JSLint found no errors.

Returns:

  • (Boolean)


37
38
39
# File 'lib/jslint.rb', line 37

def valid?
  @valid
end