Class: Headhunter::CssValidator::Response

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

Defined Under Namespace

Classes: Error

Instance Method Summary collapse

Constructor Details

#initialize(response = nil) ⇒ Response

Returns a new instance of Response.



82
83
84
# File 'lib/headhunter/css_validator.rb', line 82

def initialize(response = nil)
  @dom = Nokogiri::XML(convert_soap_to_xml(response)) if response
end

Instance Method Details

#[](key) ⇒ Object



86
87
88
# File 'lib/headhunter/css_validator.rb', line 86

def [](key)
  @dom[key] # TODO: still needed?
end

#errorsObject



94
95
96
97
98
99
100
101
102
103
104
# File 'lib/headhunter/css_validator.rb', line 94

def errors
  @dom.css('errors error').map do |error|
    Error.new( error.css('line').text.strip.to_i,
               error.css('message').text.strip[0..-3],
               errortype: error.css('errortype').text.strip,
               context: error.css('context').text.strip,
               errorsubtype: error.css('errorsubtype').text.strip,
               skippedstring: error.css('skippedstring').text.strip
             )
  end
end

#uriObject



106
107
108
# File 'lib/headhunter/css_validator.rb', line 106

def uri
  @dom.css('cssvalidationresponse > uri').text
end

#valid?Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/headhunter/css_validator.rb', line 90

def valid?
  @dom.css('validity').text == 'true'
end