Class: DatasetExplorer::ItemCollector

Inherits:
Object
  • Object
show all
Defined in:
lib/dataset_explorer/item_collector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeItemCollector

Returns a new instance of ItemCollector.



5
6
7
8
# File 'lib/dataset_explorer/item_collector.rb', line 5

def initialize
  @keys = []
  @evaluators = {}
end

Instance Attribute Details

#keysObject (readonly)

Returns the value of attribute keys.



18
19
20
# File 'lib/dataset_explorer/item_collector.rb', line 18

def keys
  @keys
end

Instance Method Details

#add(item) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/dataset_explorer/item_collector.rb', line 20

def add(item)
  unless item.is_a?(Array)
    return add_item(item)
  end

  item.each do |i|
    add_item(i, '[]')
  end
end

#explainObject



10
11
12
13
14
15
16
# File 'lib/dataset_explorer/item_collector.rb', line 10

def explain
  {}.tap do |explanation|
    @evaluators.each do |field, evaluator|
      explanation[field] = evaluator.describe
    end
  end
end