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.



67
68
69
70
# File 'lib/headhunter/html_validator.rb', line 67

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

Instance Attribute Details

#uriObject (readonly)

Returns the value of attribute uri.



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

def uri
  @uri
end

Instance Method Details

#errorsObject



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

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)


72
73
74
# File 'lib/headhunter/html_validator.rb', line 72

def valid?
  @response.empty?
end