Class: DatasetExplorer::Collector
- Inherits:
-
Object
- Object
- DatasetExplorer::Collector
- Defined in:
- lib/dataset_explorer/collector.rb
Class Method Summary collapse
Instance Method Summary collapse
- #collect(type, item) ⇒ Object
- #explain(type, format: :hash) ⇒ Object
- #explain_all(format: :hash) ⇒ Object
-
#initialize ⇒ Collector
constructor
A new instance of Collector.
Constructor Details
#initialize ⇒ Collector
Returns a new instance of Collector.
9 10 11 |
# File 'lib/dataset_explorer/collector.rb', line 9 def initialize @collectors = {} end |
Class Method Details
.instance ⇒ Object
5 6 7 |
# File 'lib/dataset_explorer/collector.rb', line 5 def self.instance @instance ||= new end |
Instance Method Details
#collect(type, item) ⇒ Object
13 14 15 |
# File 'lib/dataset_explorer/collector.rb', line 13 def collect(type, item) collector_for(type).add(item) end |
#explain(type, format: :hash) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/dataset_explorer/collector.rb', line 23 def explain(type, format: :hash) explanation = @collectors.fetch(type).explain if format == :table explanation = to_table(explanation) end explanation end |
#explain_all(format: :hash) ⇒ Object
17 18 19 20 21 |
# File 'lib/dataset_explorer/collector.rb', line 17 def explain_all(format: :hash) @collectors.keys.map do |key| [key, explain(key, format: format)] end.to_h end |