Class: Ra11y::HtmlFile

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ HtmlFile

Returns a new instance of HtmlFile.



6
7
8
# File 'lib/ra11y/html_file.rb', line 6

def initialize(path)
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



4
5
6
# File 'lib/ra11y/html_file.rb', line 4

def path
  @path
end

Instance Method Details

#errorsObject



18
19
20
# File 'lib/ra11y/html_file.rb', line 18

def errors
  @errors ||= results_by_type "error"
end

#inspectObject



30
31
32
# File 'lib/ra11y/html_file.rb', line 30

def inspect
  "#<Ra11y::HtmlFile path=\"#{path.gsub(Dir.pwd, "")}\" errors=#{errors.count} warnings=#{warnings.count} notices=#{notices.count}>"
end

#noticesObject



26
27
28
# File 'lib/ra11y/html_file.rb', line 26

def notices
  @notices ||= results_by_type "notice"
end

#perfect?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/ra11y/html_file.rb', line 10

def perfect?
  errors.empty? && warnings.empty?
end

#resultsObject



14
15
16
# File 'lib/ra11y/html_file.rb', line 14

def results
  @results ||= test["results"].map { |hash| Result.new(hash) }
end

#warningsObject



22
23
24
# File 'lib/ra11y/html_file.rb', line 22

def warnings
  @warnings ||= results_by_type "warning"
end