Class: Datasets::Wine

Inherits:
Dataset show all
Defined in:
lib/datasets/wine.rb

Defined Under Namespace

Classes: Record

Instance Attribute Summary

Attributes inherited from Dataset

#metadata

Instance Method Summary collapse

Methods inherited from Dataset

#clear_cache!, #to_table

Constructor Details

#initializeWine

Returns a new instance of Wine.


22
23
24
25
26
27
28
# File 'lib/datasets/wine.rb', line 22

def initialize
  super
  @metadata.id = 'wine'
  @metadata.name = 'Wine'
  @metadata.url = 'http://archive.ics.uci.edu/ml/datasets/wine'
  @metadata.description = -> { read_names }
end

Instance Method Details

#eachObject


30
31
32
33
34
35
36
37
38
39
40
# File 'lib/datasets/wine.rb', line 30

def each
  return to_enum(__method__) unless block_given?

  open_data do |csv|
    csv.each do |row|
      next if row[0].nil?
      record = Record.new(*row)
      yield(record)
    end
  end
end