Class: Completable::Summary
- Inherits:
-
Object
- Object
- Completable::Summary
- Defined in:
- lib/completable.rb
Overview
a class to summarize processing results
Instance Attribute Summary collapse
-
#fields_found ⇒ Object
Returns the value of attribute fields_found.
Instance Method Summary collapse
- #add_found(field) ⇒ Object
- #fields_missing ⇒ Object
-
#initialize(fields) ⇒ Summary
constructor
A new instance of Summary.
Constructor Details
#initialize(fields) ⇒ Summary
Returns a new instance of Summary.
139 140 141 142 143 144 145 146 147 148 |
# File 'lib/completable.rb', line 139 def initialize(fields) if fields.respond_to?(:keys) @fields = Array.new(fields.keys) elsif fields.respond_to?(:to_ary) @fields = Array.new(fields) else @fields = Array.new() end @fields_found = Hash.new end |
Instance Attribute Details
#fields_found ⇒ Object
Returns the value of attribute fields_found.
129 130 131 |
# File 'lib/completable.rb', line 129 def fields_found @fields_found end |
Instance Method Details
#add_found(field) ⇒ Object
150 151 152 153 154 |
# File 'lib/completable.rb', line 150 def add_found(field) count = @fields_found[field] count = 0 if !count @fields_found[field] = count + 1 end |
#fields_missing ⇒ Object
131 132 133 134 135 136 137 |
# File 'lib/completable.rb', line 131 def fields_missing if(@fields_found) @fields - @fields_found.keys else @fields end end |