Class: PnoteClient::Validators::HmlValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/pnote_client/validators/hml_validator.rb

Instance Method Summary collapse

Constructor Details

#initialize(hml_document) ⇒ HmlValidator

Returns a new instance of HmlValidator.



11
12
13
14
15
16
17
# File 'lib/pnote_client/validators/hml_validator.rb', line 11

def initialize(hml_document)
  @hml_document = hml_document
  @result = {
    errors: [],
    warnings: []
  }
end

Instance Method Details

#error_countObject



33
34
35
# File 'lib/pnote_client/validators/hml_validator.rb', line 33

def error_count
  return @result[:errors].length
end

#has_error?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/pnote_client/validators/hml_validator.rb', line 25

def has_error?
  return error_count > 0
end

#has_warning?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/pnote_client/validators/hml_validator.rb', line 29

def has_warning?
  return warning_count > 0
end

#validateObject



19
20
21
22
23
# File 'lib/pnote_client/validators/hml_validator.rb', line 19

def validate
  reset_result
  validate_document
  return @result
end

#warning_countObject



37
38
39
# File 'lib/pnote_client/validators/hml_validator.rb', line 37

def warning_count
  return @result[:warnings].length
end