Class: Datasets::Penguins

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

Overview

This dataset provides the same dataset as https://github.com/allisonhorst/palmerpenguins

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

#initializePenguins

Returns a new instance of Penguins.


88
89
90
91
92
93
94
95
# File 'lib/datasets/penguins.rb', line 88

def initialize
  super
  @metadata.id = "palmerpenguins"
  @metadata.name = "palmerpenguins"
  @metadata.url = "https://allisonhorst.github.io/palmerpenguins/"
  @metadata.licenses = ["CC0"]
  @metadata.description = "A great dataset for data exploration & visualization, as an alternative to iris"
end

Instance Method Details

#each(&block) ⇒ Object


97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/datasets/penguins.rb', line 97

def each(&block)
  return to_enum(__method__) unless block_given?

  species_classes = [
    PenguinsRawData::Adelie,
    PenguinsRawData::Chinstrap,
    PenguinsRawData::Gentoo,
  ]

  species_classes.each do |species_class|
    species_class.new.each do |raw_record|
      yield convert_record(raw_record)
    end
  end
end