Class: Datasets::PenguinsRawData::SpeciesBase

Inherits:
Dataset
  • Object
show all
Defined in:
lib/datasets/penguins.rb

Direct Known Subclasses

Adelie, Chinstrap, Gentoo

Instance Attribute Summary collapse

Attributes inherited from Dataset

#metadata

Instance Method Summary collapse

Methods inherited from Dataset

#clear_cache!, #to_table

Constructor Details

#initializeSpeciesBase

Returns a new instance of SpeciesBase.


23
24
25
26
27
28
29
30
# File 'lib/datasets/penguins.rb', line 23

def initialize
  super
  species = self.class.name.split("::").last.downcase
  @metadata.id = "palmerpenguins-raw-#{species}"
  @metadata.url = self.class::URL
  @metadata.licenses = ["CC0"]
  @data_path = cache_dir_path + "penguins" + (species + ".csv")
end

Instance Attribute Details

#data_pathObject (readonly)

Returns the value of attribute data_path


32
33
34
# File 'lib/datasets/penguins.rb', line 32

def data_path
  @data_path
end

Instance Method Details

#eachObject


34
35
36
37
38
39
40
41
42
43
44
# File 'lib/datasets/penguins.rb', line 34

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.fields)
      yield record
    end
  end
end