Class: Clausewitz::Spelling::LangResults
- Inherits:
-
Object
- Object
- Clausewitz::Spelling::LangResults
- Defined in:
- lib/clausewitz/spelling/results.rb
Instance Method Summary collapse
- #failed? ⇒ Boolean
- #failures ⇒ Object
- #ignored ⇒ Object
- #ignored? ⇒ Boolean
-
#initialize(lang, entry_results) ⇒ LangResults
constructor
A new instance of LangResults.
- #size ⇒ Object
- #to_s ⇒ Object
- #to_str(indent = 0) ⇒ Object
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
60 61 62 |
# File 'lib/clausewitz/spelling/results.rb', line 60 def failed? @entry_results.any?(&:failed?) end |
#failures ⇒ Object
64 65 66 |
# File 'lib/clausewitz/spelling/results.rb', line 64 def failures @entry_results.select(&:failed?) end |
#ignored ⇒ Object
56 57 58 |
# File 'lib/clausewitz/spelling/results.rb', line 56 def ignored @entry_results.select(&:ignored?) end |
#ignored? ⇒ Boolean
52 53 54 |
# File 'lib/clausewitz/spelling/results.rb', line 52 def ignored? false end |
#size ⇒ Object
68 69 70 |
# File 'lib/clausewitz/spelling/results.rb', line 68 def size @entry_results.size end |
#to_s ⇒ Object
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 |