Class: Clausewitz::Spelling::LangResults

Inherits:
Object
  • Object
show all
Defined in:
lib/clausewitz/spelling/results.rb

Instance Method Summary collapse

Constructor Details

#initialize(lang, entry_results) ⇒ LangResults

Returns a new instance of LangResults.



47
48
49
50
# File 'lib/clausewitz/spelling/results.rb', line 47

def initialize(lang, entry_results)
  @lang          = lang
  @entry_results = entry_results
end

Instance Method Details

#failed?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/clausewitz/spelling/results.rb', line 60

def failed?
  @entry_results.any?(&:failed?)
end

#failuresObject



64
65
66
# File 'lib/clausewitz/spelling/results.rb', line 64

def failures
  @entry_results.select(&:failed?)
end

#ignoredObject



56
57
58
# File 'lib/clausewitz/spelling/results.rb', line 56

def ignored
  @entry_results.select(&:ignored?)
end

#ignored?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/clausewitz/spelling/results.rb', line 52

def ignored?
  false
end

#sizeObject



68
69
70
# File 'lib/clausewitz/spelling/results.rb', line 68

def size
  @entry_results.size
end

#to_sObject



72
73
74
# File 'lib/clausewitz/spelling/results.rb', line 72

def to_s
  to_str
end

#to_str(indent = 0) ⇒ Object



76
77
78
79
80
81
82
83
84
# File 'lib/clausewitz/spelling/results.rb', line 76

def to_str(indent = 0)
  firstspacer = ' ' * indent
  spacer = ' ' * (indent + 2)
  failures = @entry_results.select(&:failed?)
  outlines = failures.map { |e| "#{spacer}#{e.to_str(indent + 2)}" }
  outlines = outlines.join("\n")
  outlang = failed? ? "#{@lang} has #{failures.size} keys with errors (#{size} keys checked, #{ignored.size} ignored)".red : "#{@lang} passed (#{size} keys checked, #{ignored.size} ignored)".green
  out = "#{firstspacer}#{outlang}\n#{outlines}"
end