Class: Headhunter::HtmlValidator::Response

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

Defined Under Namespace

Classes: Error

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response = nil, uri = nil) ⇒ Response

Returns a new instance of Response.



65
66
67
68
# File 'lib/headhunter/html_validator.rb', line 65

def initialize(response = nil, uri = nil)
  @response = response
  @uri      = uri
end

Instance Attribute Details

#uriObject (readonly)

Returns the value of attribute uri.



63
64
65
# File 'lib/headhunter/html_validator.rb', line 63

def uri
  @uri
end

Instance Method Details

#errorsObject



74
75
76
77
78
79
80
81
82
# File 'lib/headhunter/html_validator.rb', line 74

def errors
  @response.split("\n").map do |error|
    matches = error.match(/line (\d*) column (\d*) - (.*)/)
    Error.new( matches[1],
               matches[3],
               column: matches[2]
             )
  end
end

#valid?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/headhunter/html_validator.rb', line 70

def valid?
  @response.empty?
end