Class: Uniword::Redact::Result
- Inherits:
-
Object
- Object
- Uniword::Redact::Result
- Defined in:
- lib/uniword/redact/result.rb
Overview
Aggregated redaction result.
Instance Attribute Summary collapse
-
#by_pattern ⇒ Object
readonly
Returns the value of attribute by_pattern.
Instance Method Summary collapse
- #add(name, count) ⇒ void
-
#count ⇒ Integer
Total substitutions across all patterns.
-
#empty? ⇒ Boolean
True when zero substitutions were made.
-
#initialize ⇒ Result
constructor
A new instance of Result.
-
#patterns_matched ⇒ Array<Symbol>
Patterns that matched at least once.
Constructor Details
#initialize ⇒ Result
Returns a new instance of Result.
9 10 11 |
# File 'lib/uniword/redact/result.rb', line 9 def initialize @by_pattern = Hash.new { |h, k| h[k] = 0 } end |
Instance Attribute Details
#by_pattern ⇒ Object (readonly)
Returns the value of attribute by_pattern.
7 8 9 |
# File 'lib/uniword/redact/result.rb', line 7 def by_pattern @by_pattern end |
Instance Method Details
#add(name, count) ⇒ void
This method returns an undefined value.
16 17 18 |
# File 'lib/uniword/redact/result.rb', line 16 def add(name, count) @by_pattern[name] += count end |
#count ⇒ Integer
Total substitutions across all patterns.
23 24 25 |
# File 'lib/uniword/redact/result.rb', line 23 def count @by_pattern.values.sum end |
#empty? ⇒ Boolean
True when zero substitutions were made.
37 38 39 |
# File 'lib/uniword/redact/result.rb', line 37 def empty? count.zero? end |
#patterns_matched ⇒ Array<Symbol>
Patterns that matched at least once.
30 31 32 |
# File 'lib/uniword/redact/result.rb', line 30 def patterns_matched @by_pattern.select { |_, c| c.positive? }.keys end |